How does one manage their systems in different scenes? I want specific systems to run in specific scenes, how does one go about doing that? I know there is a default world and it seems that all existing systems will run in all scenes by default.
Do I need to create a world for each scene in this case? or do I have monobehaviour that manages the enabling and disabling of the systems somehow, I tried the mono behaviour way and I can't seem to get the reference to the systems
public class SystemsManager : MonoBehaviour
{
public string SceneName;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void UpdateSystems()
{
var world = World.DefaultGameObjectInjectionWorld;
// Systems
var systemA = world.GetExistingSystem<EntitySpawner>();
var systemB = world.GetExistingSystem<GameObjectSpawner>();
if (SceneManager.GetActiveScene().name == SceneName)
{
// Enable systems for the specified scene
systemA.Enabled = true;
systemB.Enabled = true;
}
else
{
// Disable systems for other scenes
systemA.Enabled = false;
systemB.Enabled = false;
}
}
}
Severity Code Description Project File Line Suppression State Details
Error (active) CS0315 The type 'EntitySpawner' cannot be used as type parameter 'T' in the generic type or method 'World.GetExistingSystem<T>()'. There is no boxing conversion from 'EntitySpawner' to 'Unity.Entities.ComponentSystemBase'. Assembly-CSharp D:\Unity Projects\URP3DTemplate\Assets\Scripts\SystemsManager.cs 26
Appreciate and thanks in advance for any help