Basically I have a script attached to my grass tiles that spawns a square outline over it when the mouse is hovered on it.
I need to know how to make the spawned object disappear when the mouse is taken away, I’ve made an attempt at this using OnMouseExit(); However, when you move the mouse too fast the mouse leaving the object is not detected and the outline remains on the object until you hover over it and remove the mouse again.
attached is my script that attempts to remove the tiles.
using UnityEngine;
using System.Collections;
public class GridTile : MonoBehaviour {
public bool IsMouseOver;
void Update(){
if (IsMouseOver == false) {
//byetile deletes square outline
ByeTile();
}
}
void OnMouseOver()
{
IsMouseOver = true;
}
void OnMouseExit()
{
IsMouseOver = false;
Debug.Log ("set to false");
}
public void ByeTile()
{
Destroy (gameObject);
}
}