Hello Everyone!
I have an object with a collider mesh.
I want to be able to CLICK on the object and have Text Appear.
I’ve been working with GUI text scripts but to no avail.
Any advice would be greatly appreciated.
Thank you!
K.
Here’s a script I’ve been writing to display various info about objects and how to interact with them.
var activateGUI : GUITexture;
var infoText : GUIText;
var detailsText : GUIText;
var objectName = "Object001";
var useButton = "(E)";
var doThis = "Activate";
var pressButton = "Activate";
var itemWG = 0.0;
var itemVAL = 0.0;
function Start () {
infoText.text = " ";
detailsText.text = " ";
activateGUI.guiTexture.color = Color(0,0,0,0);
}
function OnMouseOver () {
activateGUI.guiTexture.color = Color(0.5,0.5,0.5,0.5);
infoText.text = useButton + " " + doThis + " " + objectName;
detailsText.text = "VAL = " + itemVAL + " " + "|" + " WG = " + itemWG;
if (Input.GetButton(pressButton)){
Destroy(gameObject);
activateGUI.guiTexture.color = Color(0,0,0,0);
infoText.text = " ";
detailsText.text = " ";
}
}
function OnMouseExit () {
activateGUI.guiTexture.color = Color(0,0,0,0);
infoText.text = " ";
detailsText.text = " ";
}
At its current state, it works similar to the object interaction in Fallout 3, if you’ve ever played that game this should be fairly straight forward. You should be able to change this to suit your needs easily enough.
Attach it to an object that you deem to be interactive and allocate appropriate GUIText and GUITexture into the slots. It isn’t very conventional if you’re working with millions of objects though, if you are, you’re better off finding some other method of doing things.
After that find the object in the scene, select it and then drag the GUIText or GUITexture out of the Hierarchy panel to where it says GUIText or GUITexture in the inspector under the applied script name (There’s two GUITexts and oneGUITexture).