- Home /
Create animation that allow picture to come in one by one
I would like to ask some questions regarding the animation. I will have 10 pictures in the beginning of the scene. Instead of making it static (when the scene started, it just display all the 10 pictures), i would like to make some special effect/animation to the picture. For example like make them march in one by one. So i would like to ask if i have to do animation for all the 10 picture or i can just do one and control via the scripting? Any suggestion? thank you
Is the 10 pictures making up your marching animation? Or do you want 10 seperate pictures to move into your scene?
Answer by Berenger · Mar 04, 2012 at 12:21 AM
Use InvokeRepeating, or a coroutine, to iterate inside an array of Texture2D.
Sure. First, create an array of Texture2D that you can fill inside the inspector, and the index we'll use later.
var slides : Texture2D; private var index : int = 0;
Then, the coroutine which iterate index every x secondes
function Start(){ while( index < slides.Length ){ yield WaitForSeconds( x ); index++; } }
Finally, display the corresponding texture
function OnGUI(){ GUI.DrawTexture( Rect( 0, 0, Screen.width, Screen.height ), slides[index] ); }
thank you. i will try it out. But i don't understand, you mention need to call coroutine and iterate index every x seconds, where should i place the coroutine function?
I wrote "call a coroutine", noticed the mistake and edited, but it takes time to update. The coroutine here is Start. A coroutine is, to make it simple, a function that have a yield instruction, which stop the execution for some time. So you don't need to call it, it's the usual Start function, Unity will call it.
thank you. I was wondering how come not using Coroutine(). Anyway to add on some question, for example, i have 10 picture static on the scene, so after 10second, i will start playing animation on picture1, and after 20 second i will start playing animation on picture 2, after 30 second on picture3... how can i tackle this kind of thing?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Trying to check what anim clip is currently running on object 1 Answer
Empty animation clips when copying to Prefab 1 Answer
How can I reassign animation curves to play on a child object (instead of through parent)? 1 Answer
Can't Animate 0 Answers