As the title says. I finished my Monobehavior SystemManager. It has an instance of the below class for each of my systems. The monobehavior component runs GetSystem, SetSystemEnabledState, and UpdateSystemData for each in Update().
I included fields for SystemName, and WorldName to help debugging. They show the correct system names and “default world”. I’m at a lose for why changing the enabled state to false has no affect on the system.
[Serializable]
public class SystemDataRefWrapper<D,S> : ISystemManagerWrapper where D : unmanaged, IComponentData, ISystemManagerData
{
[field: SerializeField]
public bool Enabled { get; set; }
public bool EnabledFb;
public string SystemName;
public string WorldName;
public bool HasFoundSystem;
public D Data;
private S System;
private SystemHandle _handle;
bool ISystemManagerWrapper.GetSystem()
{
if (HasFoundSystem)
return true;
var systemTypeIndex = TypeManager.GetSystemTypeIndex<S>();
_handle = World.DefaultGameObjectInjectionWorld.GetExistingSystem(systemTypeIndex);
if(!_handle.Equals(default(SystemHandle)))
{
HasFoundSystem = true;
var state = World.DefaultGameObjectInjectionWorld.Unmanaged.ResolveSystemStateRef(_handle);
SystemName = state.DebugName.ToString();
var systemWorld = state.World;
WorldName = systemWorld.Name;
}
return HasFoundSystem;
}
void ISystemManagerWrapper.SetSystemEnabledState()
{
var state = World.DefaultGameObjectInjectionWorld.Unmanaged.ResolveSystemStateRef(_handle);
if(state.Enabled != Enabled)
state.Enabled = Enabled;
EnabledFb = state.Enabled;
}
void ISystemManagerWrapper.UpdateSystemData()
{
if (!EqualityComparer<D>.Default.Equals(Data, default(D)))
World.DefaultGameObjectInjectionWorld.EntityManager.SetComponentData<D>(_handle, Data);
}
}
thanks for your help!