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

Hide Image ?

Discussion in 'Scripting' started by Quast, Sep 5, 2015.

  1. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    I'm making 2d game. in my canvis there is an image. I want to show/hide.
    i did
    Code (CSharp):
    1. image1.enable = false;
    I make it GO
    Code (CSharp):
    1. image1.setactive(false);
    but not working

    any advise ?
     
    unity_finch likes this.
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEngine.UI; // Required when Using UI elements.
    5.  
    6. public class Example : MonoBehaviour[/URL]
    7. {
    8. public Image pauseMenu;
    9.  
    10. public void Start()
    11. {
    12. //Enables the pause menu UI.
    13. pauseMenu.enabled = true;
    14. }
    15. }
    16.  
    trust me. this code not working with me. it's from Unity 5.1.3 ?
     
  4. jmora256

    jmora256

    Joined:
    Jun 1, 2014
    Posts:
    3
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. public class Example : MonoBehaviour {
    5.  
    6.     public Image pauseMenu;
    7.    
    8.  
    9.     public void Start()
    10.     {
    11.      
    12.        
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update () {
    17.         if (Input.GetKeyDown(KeyCode.A))
    18.         {
    19.             pauseMenu.enabled = true;
    20.         }
    21.     }
    22.  
    23. }
    24.