Preivously in 0.51 I was using SystemBase with custom native containers inside. E.g. NativeOctree.
These containers were accessed inside other ISystems via SystemBase managed reference, dependency was combined to ensure safety, and then containers were used inside related job.
The question, how to properly store and access these types of containers?
ISystem no longer can contain managed reference types. Can store SystemHandle & resolve it via
state.WorldUnmanaged.GetUnsafeSystemRef<T>(), but there’s a big “no you’re doing something wrong” tooltip.
So, how to do it properly, and what are the options?
What I was thinking is something similar to ECB.Singleton binding of system fields to the IComponentData.
But, it requires an unsafe collection, and I’m not sure it will work. Plus, all safety would be lost.
In theory I could:
- Strip safety of the collection & make an unsafe version of it;
- Add it to the ISystem;
- “Register” a singleton entity with IComponentData that will store reference to the unsafe version of the collection;
- Access it similarly to the ECB.Singleton via SystemAPI;
- This should be BurstCompile-able for both lookup system & reading / writing system fetch
(since systems no longer interact with each other directly);
But I’m not sure whether it would be safe to read / write it across multiple systems.
If that collection is only accessed via SystemAPI.GetSingletonRW() it should ensure that dependencies are combined / correct automatically, right?
Ideally, I’d like to do the following:
- Bind persistent collection to system somehow;
- Access it for Read / Writes in other systems in async way from jobs;
- With at least some kind of safety;
- (Optionally) No manual dependency management;
Any suggestions?
