Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. 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:
    112
    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:
    35
    Do you have a more complete example of how to do this?
     
  4. Prastiwar

    Prastiwar

    Joined:
    Jul 29, 2017
    Posts:
    112
    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. }
     
  5. hellowill89

    hellowill89

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