- Home /
[FIXED & CLOSED!] How do I show and hide 3D text?
Problem fixed...
Answer by CHPedersen · Jul 02, 2014 at 07:23 AM
3D Text, like all other visible things, has a renderer with an "enabled" property. Setting it to true when entering the collider will cause it to appear, false when exiting the collider will cause it to disappear, and vice versa.
There is an example of what code to write for a OnTriggerEnter here:
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html
And an example for OnTriggerExit here:
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerExit.html
but how do i enable it? also do i need to declare it first?
Answer by Andres-Fernandez · Jul 02, 2014 at 07:23 AM
Have a reference to the text GameObject in the object that has the collider. Set your collider to isTrigger and use SetActive in your OnTriggerEnter function.
Well, the code you posted only works if the gameobject has a renderer (which I'm pretty sure it has). It wouldn't be a bad idea to add a check for the renderer component before disabling and enabling the renderer component. But sure, that code should work.
Your answer
Follow this Question
Related Questions
Displaying public variables in the inspector 2 Answers
Hide Object in Editor Only 5 Answers
How to hide AdMob ads? 1 Answer
on collision, show/hide other model scripting ? 1 Answer
Why not showing up 1 Answer