Hi ![]()
I’m having a little issue. I have unity free, and would like to have a short (about 25 seconds) cinematic when a user first loads the game. However, unity free doesn’t support movie playback, so I rendered out my cinematic as a jpeg sequence. The naming for this sequence is:
First_Run_Cinematic_00000
to
First_Run_Cinematic_00600
These images are imported into an assets folder I have created called ‘Imported Assets’ and inside that a folder called ‘Cinematic Pictures’
So far, what I have is an adapted script from these forums that I found (and understood), that I apply to my main camera that allows me to select how many frames I have, and drag in each frame of my cinematic.
This is the code I’m using:
#pragma strict
var waitTime : float = 0.5;
var textures : Texture2D[];
private var i : int = 0;
// Use this for initialization
function Update ()
{
Invoke("LoopTexture",waitTime);
}
function LoopTexture()
{
//Debug.Log(i);
//renderer.material.mainTexture = textures[i];
if (i < textures.Length-1)
i ++;
else
i = 0;
CancelInvoke("LoopTexture");
}
function OnGUI () {
GUI.DrawTexture (Rect (0,0,Screen.width,Screen.height), textures[i]);
}
I don’t want to have to drag 600 images into the script, so what I am attempting to do is automatically load the images into the array via a piece of javascript. I have written some pseudo-code (bits of objective C, C++ and javascript) all lumped together to do this, but I am not proficient enough in unity javascript to write it myself.
Could one of you kind fellows here be so kind as to port it over into unity javascript for me.
var textures : texture 2D[]; //create the array to hold my textures
for(int i = 0, i< textures.length, i++){
if(i<99){textures[i] = "First_Run_Cinematic_00" + i};
if(i<9){textures[i] = "First_Run_Cinematic_000" + i};
if(i<-1){textures[i] = "First_Run_Cinematic_0000" + i};
}
Thanks ![]()