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

Trying to enable a Canvas from another object

Discussion in 'Scripting' started by Blar321, Nov 21, 2015.

  1. Blar321

    Blar321

    Joined:
    Aug 30, 2015
    Posts:
    25
    Hello everybody,
    I am trying to enable an external canvas with the click of a button in-game. Any ideas? Thanks!
    Nick
     
    Last edited: Nov 21, 2015
  2. Blar321

    Blar321

    Joined:
    Aug 30, 2015
    Posts:
    25
  3. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    Attach this to a button and call TurnOnCanvas in OnClick.

    Code (CSharp):
    1. public GameObject canvas;
    2.  
    3. public void TurnOnCanvas ()
    4. {
    5.       canvas.SetActive (true);
    6. }
    You can modify this with a bool to turn in back off again if you need.
     
    Last edited: Nov 22, 2015
  4. btft

    btft

    Joined:
    Aug 11, 2015
    Posts:
    14
    Actually you don't need a script for that.
    You can use underlying method of GameObject:
    upload_2015-11-22_2-45-39.png
     
    RavenOfCode, Kiwasi and Polymorphik like this.