- Home /
Question by
GraviterX · Jun 04, 2014 at 01:55 AM ·
javascriptguitexturedoorhand
Door Problem
Hi all! I have this simple door script:
var AudioFile : AudioClip;
function OnTriggerStay (other : Collider) {
if (Input.GetButtonDown("Fire1")){
animation.Play("open");
audio.clip = AudioFile;
audio.Play();
}
}
I want to add a GUI texture so that a hand texture appears when in the trigger. I have no clue how to do this. Can anyone link tutorials or code? Thanks!
Comment
Answer by CrimsonIndustry · Jun 04, 2014 at 05:44 AM
You'll want to use the OnMouseEnter() and OnMouseExit() methods. When you mouseover the gameobject that is your trigger, it is called. C# usage:
using UnityEngine;
using System.Collections;
public class ScriptName : MonoBehaviour {
void OnMouseEnter(){
Debug.Log("Enter");
}
void OnMouseExit(){
Debug.Log("Exit");
}
}
If I understand correctly, this is what you want.
If this answer works, please mark it as accepted. If not, please explain what else you need.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150728im_/https://answers.unity.com/themes/thub/images/avi.jpg)