I want to instantiate a “highlight” halo on an object when I mouse over it that disappears when my mouse is not on the object. I get the following error using C#, and using DestroyImmediate results in other errors.
Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate (theObject, true);
using UnityEngine;
using System.Collections;
public class UnitController : MonoBehaviour {
public Transform myHighlight;
void OnMouseEnter() {
Instantiate(myHighlight, new Vector3(0, 0.1f, 0), Quaternion.Euler(90.0f, 0, 0));
}
void OnMouseExit() {
Destroy(myHighlight);
}
}