Hi Guys,
I just create a VR APP for running a 360 video on my phone with google cardboard SDK but need to do some
trigger for that .
so my aims is when I open the app and the video will be Autoplay when its start, 3mins later (the end of the video), there are 2 button (I made it already its a 3D Cube) appear for the viewer and now my question is how to make it appear?
Basiclly, my idea is make a timer that count to 3 mins and make the button appear. Is it right?
btw, does anyone can give me some help about this? I don’t even know how to create a timer, thank you!
Have a good day
to wait 3 minutes you can use a coroutine:
// somewhere when you start the video (inside a MonoBehaviour)
this.StartCoroutine(WaitAndShowButtons());
// coroutine function
System.Collections.IEnumerator WaitAndShowButtons()
{
yield return new WaitForSeconds(3 * 60); // wait 3 minutes
// show buttons here
}
If your button is just a UI-Image you can use the CrossFadeAlpha() method of it to fade it in.
alternately you can also adjust the alpha inside a coroutine with a loop…
PS: code not tested
Thank you so much Hosnkobf !
one more question, what should i use this code in? should I make it in my button ? my button is a 3D button , thank you!
probably not in the button because maybe you have the buttons inactive until you show them. This would be better for performance I guess, but when a component is inactive or disabled no coroutines can be started on that component (AFAIK).
I would do it in a kind of manager component which is responsible for showing the video as well as the buttons. The logic of these two kind of relate to each other so I think it would be a good idea to put it in the same place.
Thank you very much for your help Hosnkobf 