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 Canvas for MainMenü

Discussion in 'Scripting' started by EmretheGanjaRaiders, Oct 16, 2015.

  1. EmretheGanjaRaiders

    EmretheGanjaRaiders

    Joined:
    Dec 27, 2014
    Posts:
    21
    Hi, i have tried to write a simple Script to disable the "Mainmenu" canvas if i press play and enable than the "levels" Canvas but they do tell me that : BCE0019: 'enable' is not a member of 'UnityEngine.Canvas'.
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var levels : Canvas;
    4. var mainmenu : Canvas;
    5.  
    6. function OnClick(){
    7.  
    8.     mainmenu.enable = false;
    9.     levels.enable = true;
    10.  
    11. }
    what im do wrong ?
    i want plug this script into a gameobject and select it from the "Button" Component
     
  2. GeekStories

    GeekStories

    Joined:
    Jan 22, 2015
    Posts:
    74
  3. ofltunisia

    ofltunisia

    Joined:
    Sep 25, 2014
    Posts:
    16
    for enabling and disabling canvas i find it very helpful if i declare a public variable canvas in the my script and in unity i assign it to whatever canvas i want to display/not .
    maybe this will help ? it works for me very well :)