hi, I’m new to unity and scripting
I’m making a menu screen from 3D text, so far I have it so when the user rolls over each text the text changes colour but I also want another 3D text to appear for at least 10 seconds and to be removed if the user rolls over another 3D text object.
any ideas? so far i’ve looked into onmouseover script to enable the renderer but I can’t find anything that really helps me…
Well you could use OnMouseEnter. When the mouse goes over a 3D text object, you have a reference to another one in your script, set the renderer.enabled property to true, and then wait 10 seconds and set it to false.
So… and I’m not as experienced as many people here, so there may be better ways. But possibly… (if you’re using C#):
public Renderer otherText; // put reference to other one here
void OnMouseEnter()
{
StartCoroutine(ShowText());
}
IEnumerator ShowText()
{
otherText.enabled = true;
yield return new WaitForSeconds(10.0f);
otherText.enabled = false;
}
That’s if you want it to appear for 10 seconds and then disappear. But I may have misunderstood. If you want it to disappear when the user puts the mouse over some other object, then you could put an OnMouseEnter on those objects and then set otherText.enabled to false when that OnMouseEnter gets called (using the public Renderer otherText field). You can just drag that in through the inspector.
Let me know if I misunderstood.
Edit: actually, it appears OnMouseEnter can be a coroutine… so you could skip the new function entirely.