#How to use ICleanUpSharedComponentData?
1 messages · Page 1 of 1 (latest)
no need for value, just index is enough
but if value is small (pointer)
then sure,why not
basically, if (!toDestroyQuery.IsEmptyNoFilter) { //store all values to hash set} and then go over that hash set doing extraQuery.SetSharedComponentFilter(index);`
extraQuery.IsEmptyNoFilter
jeez, discord is mad
shouldn't be unelss you use anything managed
in this case
you'll get throws on startup when TypeManager will assert it's good to go
and will suggest to implement all necessary interfaces for managed support
what init problem?
haven't read whole post
2nd one?
To initialize the data...?
well
biggest question
why can't you just make your blob in baking
and do you need to create it in runtime
then just normal cleanup init workflow will do:
have a component X and query for WithAll<X>().WithNone<Y>(). Add Y to it.
No need to remove X
oh
I see your problem
because it's a cleanup - it's forced to be readded all the time
hmm
I solved similiar problem this way:
- I created completely separate from entities storage to access external plugin API.
- I baked data about objects that needs instantiation into single shared component (per subscene). Instantiation part runs on those entities, instead of actual users.
- All "user" entities had only an index to array on shared comp for their asset (this is basically how graphics RenderMeshArray works).
- Whenever I had to call external API, I simply looked up objects via array index and shared comp index.
assuming you have to access your object only on main thread - that's probably the best solution I know
if you want to access your object via "user" entities in jobs: you can also post process all your prefabs, adding runtime only component (normal, not cleanup), so all freshly instantiated have a pointer component
cleanup in this case will only run when special entities get destroyed. Without taking 0 users into account.
instead of managing allocations via shared component - you manage them via special entities
shared comp here is mostly to hold source references (or data) and to let Unity resolve it's index (because it's going to be unique and persistent)
just like RenderMeshArray, which contains array of meshes. And MaterialMeshInfo contains index to that array
this combined provides a unique combination of RenderMeshArray index and mesh index inside that array.
this is just for managing baking data though
once in runtime, you can just postprocess all user entities to have a direct component with pointer
unless you need custom deallocation - it'll work when subscene is unloaded
by default this approach assumes you only need deallocation when subscene is unloaded
deallocation of your c++ objects
their lifetime starts when subscene is loaded and ends with it being unloaded
not really
you can still deallocate
I just haven't though tof it yet
I guess you could just run a separate system loop to check if user count is not empty from time to time
what prefabs?
c++ or?
I have no idea what prefactured even means here btw 😅
no idea about your case
in my case: I needed it specifically to post process entity prefabs
so when you instantiate them, they automatically have access to plugin API