The issue according to my debug log is that my ints counts with no problem however the int to string conversion continues to apply to the original value not the updated counter on runtime. (there are some unused private's here for testing) & the frame values are all good. a screen shot of my debug log: http://c2n.me/39GlfuI - as you can see the counter increases but 'frame' doesn't.
Hopefully this is self explanatory
using UnityEngine;
using System.Collections;
public class imagecycle : MonoBehaviour
{
public string Startingframe;
private string Nextframe;
private int framecomp = 0;
private int frameint;
private int framestep = 1;
private int maxframe = 119;
private string framestring;
// Use this for initialization
void Start ()
{
Nextframe = ("frame_000");
frameint = 20; // currently adding one to this and resetting on update
}
// Update is called once per frame
void Update ()
{
frameint += framestep;
//Converts framestring to int of frameint -updating frame
framestring = frameint.ToString();
Debug.Log (frameint);
// replaces loaded texture recourse with frame string:
Nextframe = Nextframe.Replace ("000", framestring);
// Loads texture into Currentframe:
Texture Currentframe = Resources.Load (Nextframe) as Texture;
// Applies texture:
renderer.material.mainTexture = Currentframe;
Debug.Log (Currentframe);
if (frameint > 119)
{
frameint = 1;
}
}
void LateUpdate()
{
}
}
that is because in first your next frame is "frame_000"
so the replace method will replace 000
with 21
as you can see but after that your nextFrame variable is "frame_21"
so there is no "000"
in your string so your replace method wont do anything so nextFrame
will stay at frame_21
Nextframe = Nextframe.Replace ("000", framestring);
wont do anything after the first replace because its string doesnt conatins 000