#Can't enable/disable my system from monobehaviour

1 messages · Page 1 of 1 (latest)

hallow cliff
#

I have this function:

public static void ToggleUnmanagedSystem<T>(World world, bool state) where T : unmanaged, ISystem
{
    world = world == null ? World.DefaultGameObjectInjectionWorld : world;
    var handle = world.GetExistingSystem<T>();
    var system = world.Unmanaged.ResolveSystemStateRef(handle);
    system.Enabled = state;
}```

I call this from a monobehaviour in an update function:
```csharp
private void Update()
{
    if (IsStarted)
        SystemUtils.EnableUnmanagedSystem<TestSystem>(World.DefaultGameObjectInjectionWorld);
    if (Cancel)
        SystemUtils.DisabledUnmanagedSystem<TestSystem>(World.DefaultGameObjectInjectionWorld);
}

But in the editor systems window it shows the system greyed out. What am i getting wrong here?

torn kernel
#

Not familiar with this but you're not using ResolveSystemStateRef by ref

hallow cliff
#

oh that might be it let me test