World.Active.GetOrCreateSystem() is depreciated.
Thanks.
World.Active.GetOrCreateSystem() is depreciated.
Thanks.
its just World.GetOrCreateSystem if you mean systems.
I’m using it from MonoBehvaiour so I’m not sure if I can use World
void FixedUpdate()
{
group = World.Active.GetOrCreateSystem();
group.Update();
}
I am not getting any compilation errors but there is a null reference exception when assigning group
for accessing within monobehaviours use
World.DefaultGameObjectInjectionWorld.GetOrCreateSystem (“Active” was so much simpler but apparently misused and not the correct context of active in most cases)
Thanks!
Unfortunately I still receive a null reference exception when using the new API.
Are you using a custom bootstrap? If so you’ll need to set world yourself.
Thanks for your response! It’s been a while since I’ve worked on this so I’m not sure if what I’m doing is a bootstrap method or not.
I just have
[DisableAutoCreation]
public class ExampleSystemGroup : ComponentSystemGroup {}
void FixedUpdate()
{
//group = World.Active.GetOrCreateManager<ExampleSystemGroup>();
group = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<ExampleSystemGroup>();
group.Update();
}
For some reason group = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem();results in NullReferenceException
Thanks a lot for your help!
How is this done?
Have you set the define UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP or have you implemented ICustomBootstrap
DefaultGameObjectInjectionWorld is set in DefaultWorldInitialization
public static void Initialize(string defaultWorldName, bool editorWorld)
{
RegisterUnloadOrPlayModeChangeShutdown();
if (!editorWorld)
{
var bootStrap = CreateBootStrap();
if (bootStrap != null && bootStrap.Initialize(defaultWorldName))
return;
}
var world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = world;
So this won’t be called if you either disable auto bootstrap or your custom bootstrap returns true, in which case you should be setting it yourself.