I want to have each model’s corresponding name to show and have selected model to glow, when I click them.
I have managed to drag the 3 models into the scene, but from here on, I am clueless. What do I need to do next?
using UnityEngine;
using System.Collections;
public class meshcolor : MonoBehaviour {
private Color StartColor;
public bool selected;
public Color MouseOverColor = Color.yellow;
// Use this for initialization
void Start ()
{
if(renderer != null)
if(renderer.material != null)
StartColor = renderer.material.color;
}
// Update is called once per frame
void Update () {
}
void OnMouseEnter()
{
selected=true;
Debug.Log (gameObject.name);
if(renderer != null)
if(renderer.material != null)
renderer.material.color = MouseOverColor;
}
void OnGUI() {
if(selected) //set your selected variable in the OnMouseDown method
GUI.Label(new Rect(40, 50, 400, 22), GetComponent<MeshFilter>().mesh.name);
// GUI.Label(new Rect(60, 70, 400, 22), GetComponent<MeshFilter>().mesh.name);
}
void OnMouseOver ()
{
}
void OnMouseExit()
{
if(renderer != null)
if(renderer.material != null)
renderer.material.color = StartColor;
}
}
I want to add glow on whole object on mouse click.