I’ve been trying to place all my images inside one gameObject and change its texture material depending on the frame rate & Time.time. I couldn’t seem to find a workaround for converting my texture materials(objects) as an int so i could increment it as if it were an actual video with the right amount of FPS. I was also wondering if I could load a set of images inside one folder which can be located in multiple directories? I put comments in the code too.
Here is the code:
using UnityEngine;
using System.Collections;
//Dynamic Arrays require using collections.generics
using System.Collections.Generic; //Make a generic list?
public class VideoT : MonoBehaviour {
public List<int> totalpictures; //Public list
string imageFolderName = "Biglang Liko - Ron Henley feat (10-4-2013 6-42-24 PM)";
public bool MakeTexture= false;
//ArrayList pictures= new ArrayList();
//public int[0] totalpictures = 6000;
bool loop= false;
int counter= 0;
bool Film = true;
float PictureRateInSeconds = 1;
private float nextPic = 0;
Object[] texturesL; // all the pictures for the video treated as a list of objects
void Start (){
totalpictures = new List<int>()[6000];
if(Film == true){
PictureRateInSeconds = 0.04166666666666666666f;
}
//Object[] textures = Resources.LoadAll(imageFolderName);
texturesL = Resources.LoadAll(imageFolderName); //Is it possible to load resources from multiple directories? a->b->c->picturesfolder
int[] textures = texturesL as int; //
for(int i= 0; i < textures.Length; i++){
Debug.Log("found TEXTURES");
totalpictures.Add(textures*);*
-
}*
-
}*
-
void Update (){*
-
if(Time.time > nextPic){*
-
nextPic = Time.time + PictureRateInSeconds; // FPS*
-
counter += 1;*
-
if(MakeTexture == true){*
-
renderer.material.mainTexture = totalpictures[counter]; //*
-
}*
-
}*
-
if(counter >= totalpictures.length){*
-
//if(counter >= totalpictures.GetRange){*
-
Debug.Log(“exceeding material length”);*
-
if(loop == true){*
-
counter = 0; // goes back to first frame*
-
}*
-
}*
-
}*
}