Hey guys, I tried to do a video with transparency but I got some problems, now I’m using an image sequence to do an animated texture by my self, I done the code, and its all working but I have 70 png’s sequences to link one per one.
I’m using public Texture[] texture
Can I link a folder and get the images inside or any other solution to don’t drag pngs one per one ?
If you take a look at the Unity Interface, you will see a tiny lock icon at the top right of the Inspector opposite the ‘Inspector’ tab. To load all of your images at once:
- Select the game object with the above script
- Click on the ‘lock’ icon to lock the veiw
- Go to your textures and select the ones you want
- Drag and drop the whole list to the ‘texture’ variable
- Click on the ‘lock’ icon again to unlock the view
I’m posting there to help everyone that have the same problem.
I done some modifications on my code, this is a code that pass texture per texture like a MovieTexture, you can use it when you need a transparency on your video.
Code:
using UnityEngine;
using System.Collections;
public class gifAnimate : MonoBehaviour
{
//Can't be Texture, you need create an Object and later convert in Texture
public Object[] botao;
//Change this for speed
public float framesPerSecond = 10;
void Start()
{
//Change "MaoEsquerda" for the Folder name (thanks robertbu)
botao = Resources.LoadAll("MaoEsquerda");
}
void Update()
{
int index = (int) (Time.time * framesPerSecond) % botao.Length;
//Now you convert the Object to texture
renderer.material.mainTexture = botao[index] as Texture;
}
}
Remember that you need to create a folder called Resources and put a folder with the name that you want, on my case, “MaoEsquerda”. Enjoy =)