- Home /
How to add all sequence images at once in array.
hi there
i am using this script to play texture sequence on game object.
var frames : Texture2D[];
var framesPerSecond = 10.0;
function Update () {
var index : int = Time.time * framesPerSecond;
index = index % frames.Length;
renderer.material.mainTexture = frames[index];
}
my prob is i have around 400 texture images. and i want to add this all 400 texture images in array. for that i have to drag drop each and every frame on array. and that really time consuming.
is there any way i can add all images at once in array..
thanks
Answer by smoggach · Nov 27, 2014 at 02:26 PM
Yes, but are you sure it's a good idea? Assigning these 400 textures to an array in the editor will mean that at runtime you will have 400 textures loaded into memory when you are only showing one at a time.
In any case you'll probably have to stash all your images in a Resources folder and use LoadAll: http://docs.unity3d.com/ScriptReference/Resources.LoadAll.html
If you really want to have them all in that array in the inspector follow these steps: 1) click on the GameObject who has the script with the array you want to fill. 2) press the little lock icon in the top right of the inspector. 3) Select all the textures you want to add 4) Drag them over to the array property in the inspector.
You have to drag it over the actual property area (not the individual elements or size, the space above that)
Thank you So much .. that helps ..now my problem my sequence is not in order. how do i sort it to sequentially.