Hello i have a major problem, im creating a strategy game and i have it so if i press on my “worker” then he will be “selected” and a blue ring shows under his feet, but i want it so if im clicking anywhere but now on the worker, then the ring will disapear. Any ideas? here is my script:
(JS)
#pragma strict
var SelectedRing : GameObject;
var Selected : boolean = false;
var showGUI : boolean = false;
var WorkerSpawn : GameObject;
var Worker : GameObject;
function Start ()
{
SelectedRing.SetActive(false);
}
function OnMouseDown ()
{
Selected = true;
SelectedRing.SetActive(true);
}
function OnGUI ()
{
if(showGUI == true)
{
if(GUI.Button(new Rect( 100, 50, 100, 100), "Spawn Worker"))
{
Instantiate(Worker, WorkerSpawn.transform.position, Quaternion.identity);
}
}
}