Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Disable/Enable script using script

Discussion in 'Scripting' started by three2wan, Dec 20, 2015.

  1. three2wan

    three2wan

    Joined:
    Jul 28, 2015
    Posts:
    25
    It may sound like noob question but is it possible to enable/disable other scripts using script? How to do it?
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    Code (csharp):
    1.  
    2. ScriptName myscript = GetComponent<ScriptName>();
    3.  
    4. myscript.enabled = false;
    5.  
     
    three2wan likes this.
  3. three2wan

    three2wan

    Joined:
    Jul 28, 2015
    Posts:
    25