Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Enabling and Disabling Systems for Unity ECS

Discussion in 'Entity Component System and C# Job system' started by Jotunheimr, May 23, 2018.

  1. Jotunheimr

    Jotunheimr

    Joined:
    Dec 4, 2012
    Posts:
    1
    Is there a way to enable and disable individual systems programmatically for Unity ECS?
     
  2. Prastiwar

    Prastiwar

    Joined:
    Jul 29, 2017
    Posts:
    125
    Yes, systems, so ScriptBehaviourManagers have property "Enabled"

    EDIT: In newer version Enabled property is from ComponentSystemBase
     
    Last edited: Jun 2, 2018
    starikcetin, 5argon and Jotunheimr like this.
  3. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    36
    Do you have a more complete example of how to do this?
     
  4. Prastiwar

    Prastiwar

    Joined:
    Jul 29, 2017
    Posts:
    125
    Code (CSharp):
    1. public class ComponentSys : ComponentSystem
    2. {
    3.     [Inject] private SomeSystem someSystem;
    4.  
    5.     protected override void OnUpdate()
    6.     {
    7.         if (disableSomeSystem)
    8.             someSystem.Enabled = false;
    9.     }
    10. }
    or

    Code (CSharp):
    1. public class SomeClass : MonoBehaviour
    2. {
    3.     private void SomeMethod()
    4.     {
    5.         World.Active.GetExistingManager<SomeSystem>().Enabled = false;
    6.     }
    7. }
     
    stylophone and Bas-Smit like this.
  5. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    36
    I see, awesome. I didn't know the system would be the type of the `GetExistingManager` call.