using UnityEngine;
using System.Collections;
public class Selectable : MonoBehaviour {
bool Selected;
// Use this for initialization
void Start () {
Selected = false;
}
// Update is called once per frame
void Update () {
if (Selected) {
if (Input.GetKeyDown(KeyCode.Escape)){Selected = false;}
Transform selectionDisk;
selectionDisk = Instantiate(selectionHalo, transform.position, transform.rotation) as Transform;
}
}
void OnMouseDown(){
Selected = true;
}
}
The Script gets attached to any game object that I want to be able to select. So far the screen just looks at a cube, but the cube doesn’t do anything on click. And now the compiler says the prefab for selection halo doesnt exist. I added a render call to change the color instead, but still no work.
Does it have a collider attached? How is it set up? What is your scene setup like?
– Benproductions1i don't see any OnCollision or OnTrigger functions here...i'm not really an expert but how exactly does your selection work? if you can tell us that maybe we can understand the problem better...
– AuggieFrom what we can see, nothing calls OnMouseDown.
– liamcaryOnMouseDown is a monobehaviour function, it need not be called. what he is missing is a collider I guess. Check if selectionHalo object has some kind of collider attached to it.
– flamyThanks for the responses, but both the cube this script attaches to and the selection halo I am instantiating both include colliders as part of the game objects.
– _Andros