Click cube > show/hide canvas include text.
I’ve put this script into the cube, and when I click the cube it will show the Canvas. I haven’t been clicking on the cube but, the canvas has already come out. and now have problem
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class MouseDownText : MonoBehaviour {
public Canvas myCanvas;
// Use this for initialization
void Start () {
myCanvas = GetComponent<Canvas> ();
myCanvas.enabled = false;
}
// Update is called once per frame
void Update () {
}
void OnMouseDown()
{
// for switch on/off
if (myCanvas.enabled)
myCanvas.enabled = false;
else
myCanvas.enabled = true;
}
}
in cube. canvas already in cube.