Hey there folks,
I have been following a post at http://forum.unity3d.com/threads/3929-Proximity-trigger-help?highlight=Triggers+GuiTextures which was about applying script to a trigger in order to fade in a GUITexture as you enter the trigger and fade out as you leave.
I am using this for tutorial and guidance purposes for a game I am creating and after following the forum post I have got it working…sort of. Basically I have applied the script:
/
/ fade GUITexture in on trigger enter, then out on trigger exit.
var myGui: GUITexture;
var fadeSpeed : float = 1;
function OnTriggerEnter () {
myGui.active = true;
myGui.color.a = 0;
for (t = 0.0; t < fadeSpeed; t+= Time.deltaTime) {
myGui.color.a = Mathf.Lerp (0, 1, t / fadeSpeed);
yield;
}
}
function OnTriggerExit () {
for (t = 0.0; t < fadeSpeed; t+= Time.deltaTime) {
myGui.color.a = Mathf.Lerp (1, 0, t / fadeSpeed);
yield;
}
myGui.active = false;
}
to a sphere then selected my GUITexture “Tutorial_01” on the drop down menu the script creates. The GUITexture is on the scene and is visible from the offset. When you hit the trigger the GUITexture will then fade in and fade out once you have left the trigger. The problem is I don’t want the GUITexture to be visible from the start and only when the player enters the Trigger. It is a problem which the person who posted on the original forum post had yet he managed to resolve it by unchecking the game object rather than the GUItexture.
This doesn’t seem to work for me, if I de-select the GameObject and not the GUItexture it still shows at start, if I deselect the GUI texture and NOT the Game Object it doesn’t show at all, and the same if I de-select both.
If anybody can see where I am going wrong and point me in the right direction it would be greatly appreciated.