Question by
hokie94 · Feb 13, 2017 at 03:49 PM ·
canvas3d modelenable and disable script
Enable a Canvas Image when 3D Object is Clicked
Hi I am new to unity and coding. I want to to click on a 3D building and have a canvas image pop up and then disappear when clicked again. I've searched the internet for an answer but no luck. See images below for what I would like to happen. Thanks!
Currently using this code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Example : MonoBehaviour
{
private Image image;
void Start()
{
GameObject go = GameObject.Find("Public Safety Building");
if (!go) return;
image = go.GetComponent<Image>();
}
void OnMouseDown()
{
if (image)
image.enabled = !image.enabled;
}
}
screen-shotsm2.jpg
(53.4 kB)
screen-shotsm3.jpg
(47.2 kB)
Comment
Your answer
Follow this Question
Related Questions
How do I present a desktop canvas for a VR experience without this warning? 0 Answers
reflection probe rendering canvas 0 Answers
Image (WebCamTexture) jumps on Android 0 Answers
Block Raycast with Ui in Andoid 0 Answers
How do i move a canvas? 0 Answers