Is there an Attribute or any other way, which executes the OnCreate (System) Function after the Baking?
I have found [CreateAfter], but I can't seem to figure out which System it needs
#How to execute OnCreate (System) after Baking?
1 messages · Page 1 of 1 (latest)
baking does not happen in build
it's editor only
and systems are created before scene is loaded (and all subscenes inside of it)
unless ofc you disable automatic world creation
so if I have 10 Spawners in my Subscene, which get baked into Entities, then I won't be able to access them using a Query from the OnCreate (System) function, since OnCreate always gets called before the Scene is loaded?
yes, you can't
even after scene is loaded, subscenes will load async
so it'll be some time until they do
so you should not rely on System lifecycle for game logic
that is anti-pattern
If it has to exists before the Scene loading, then ScriptableObjects could be used right? But if that’s the case then I would still need to put them through an Authoring process, so it lands in a Component (or maybe I am thinking too OOP like).
Or it would be possible to read the ScriptableObject file, give it the references it needs and then create those 10 Spawner Entities in OnCreate, am I right?
if it's some settings data
then you can just use Resources.Load
yeah
oh wait
no
what you want is anti-pattern
and should not be done
instead you should just make some kind of callback that will create your 10 spawners
or just load them as subscene
I see, so either load them in a Subscene and spawn the Characters from the Mono class or make a callback
But can I call my ISystem functions from a Mono class? Because I have only figured out a way to do it with SystemBase
That's how I have done it with SystemBase
no and you shouldn't
if you want to go with ECS
entry point should be from within ECS
not from within mono
So the only valid ECS solution would be to create the Entities from the Mono class (since it has the Prefab references) or to get the CharacterSpawnerComponents once from Update?
I am not even sure if I should call the creation of Entities from Mono a valid ECS solution
no
entity prefabs only exist in subscenes
I think you should just find some tutorials on ECS first
I have already watched plentiful tutorials and read many posts regarding DOTS.
What I want is to have predefined Spawner Positions (each with their own spawnable Prefabs) in the World, which I place from the Editor
Those Spawners use Authoring where they save the needed Data in ICompoent and then the Entities should get spawned by my System
But as you said, Scene and SubScene loading happens after the Systems are created. So I can't get the Data (which is on the Spawner, in the Scene) before my System gets created. So the solutions I could come up with were the mentioned ones
I mean tutorials on different practices, not on API
what you can do is just put all your spawners in subscene
on all predefined positions
and query over them
to do logic associated with their data
that's as simple as it can get and ECS friendly approach
Do you mean DOD?
I have been initially doing for each queries in OnUpdate, but Unity gave me a warning that it's better to make a query in OnCreate and then reuse it in OnUpdate that's where my initial problem came from