- Home /
 
Canvas Hide / Show with 3 clickable Objects
Hello everybody,
I have a problem and could need some help. I'm a beginner at coding.

Each Object here (Planets + Asteroidbelt) has its own Canvas with Button & Text. I've wrote a script that is able to change between the Objects with MouseOver & MouseExit and it works fine but I want to switch between Objects with Mouseclicking, not hovering. I tried it with void MouseButtonDown(), but the opposite to this is missing, there is no "MouseButtonExit" or sth similar to this. 
How would someone expierienced approach this?
My Code is:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class PlanetCanvas : MonoBehaviour {
 
 
     public Canvas TextCanvas = null;
 
 
 
     void Start()
     {
         TextCanvas.enabled = false;
     }
 
     void SetCanvasState(bool currentState)
     {
 
         TextCanvas.enabled = currentState;
     }
 
 /*    void OnMouseDown ()
     {
         SetCanvasState (true);
     }*/
         
     void OnMouseOver() 
     {
         SetCanvasState(true);
     }
 
     void OnMouseExit()
     {
         SetCanvasState(false);
     }
 
 }
 
              Your answer
 
             Follow this Question
Related Questions
Layers Show/Hide not hiding children with showing parent 0 Answers
how to make a menu open and close with the same button 3 Answers
hide show canvas and ui elements at start 1 Answer
Show GUI on collision 2 Answers
Enemy attacking enemy when defeated 1 Answer