Tower Defense 2D showing and hiding tower choose UI above building place
Hi, So I have some sprites Buildpoints in the map and I would like to click on the build, which would display the UI canvas, and I would be able to click on the buttons in the UI or by clicking elswhere hide the canvas, but I have the problem that I am not able to click on the buttons, because its "ClickElswhereTheBuildpoint" and it hides the canvas when I click on it. Iam rookie, I know what I want but I dont know the commands and syntax and I dont have much time to look for it. Thanks for help
this is my code of the buildpoint, to "public GameObject buildCanvas" I drag in inspector the canvas which is also child of the buildpoint.
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Buildpoint : MonoBehaviour { public Color hoverColor; private Renderer rend; private Color startColor; public GameObject buildCanvas; bool OnMouseOver = false; void Start() { rend = GetComponent<Renderer>(); startColor = rend.material.color; } void Update() { if ((Input.GetMouseButtonDown(0)) && (!OnMouseOver)) buildCanvas.SetActive(false); } void OnMouseDown() { buildCanvas.SetActive(true); } void OnMouseEnter() { rend.material.color = hoverColor; OnMouseOver = true; } void OnMouseExit() { rend.material.color = startColor; OnMouseOver = false; } }
Your answer
![](https://koobas.hobune.stream/wayback/20220612225323im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dragging child item in Horizontal Layout Group 0 Answers
Unity2D UI Image sprite to fill frame 1 Answer
UI inputfield not shows mobile keyboard on click 0 Answers
Overlap ScrollRect 1 Answer
How to make this shop animation and unlock system? 0 Answers