2D 'Run' n 'Jump' Animation question??

hi
i am trying to make 2D side-scroller game where my character(4 leg animal) just running and jumping(signal & double) so basically my question is i have one png file in that includes 4 frame for running & 8 frame for jumping so how can i define in the script that when i pressed space then use the jump frames and hide the run fames and when i land on the ground then start again my running frames

basically running is automatically no need to control just one key control space to jump and double space to double jump .

any idea how to do that in unity
Thanks

If you want to know how to make something happen when you press keys,

you should have a look at Input.GetAxis or Input.GetButton.

For changing the texture, you can use

var jumpAnimation1 : Texture;

renderer.material.mainTexture = jumpAnimation1;

Don't forget to assign a texture to the script in the inspector before running it.

For using images for several animation states which are stored in 1 texture file ('texture atlas'), there's a way to do it by changing offset and scale of your texture. described here.