Новый вопрос - при анимации требуется не сдвигать текстуру на спрайте, а менять сами файлы текстуры ( в каждом файле свой кадр ). Подскажите как это сделать? Надо наверно сделать заготовку массива текстур, и потом накладывать их на мешь меняя индекс в массиве. Подскажите тип данных и ф-ию наложения. Лучше в виде фрагментов кода. Спасибо.
Спасибо, уже додумался.... вроде получилось... ура!...
public class Animator : MonoBehaviour
{
float time=0;
float frame_time=1000;
public int frame=0;
public Texture [] tx;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey("z"))
{
transform.Translate(Vector3.left * Time.deltaTime* 100);
time+=Time.deltaTime;
frame=((int)(time*frame_time))%8;
renderer.material.SetTexture("_MainTex", tx[frame]);
}
else
{
if (Input.GetKey("c"))
{
transform.Translate(Vector3.right * Time.deltaTime* 100);
time+=Time.deltaTime;
frame=((int)(time*frame_time))%8;
renderer.material.SetTexture("_MainTex", tx[frame]);
}
else
{
time=0;
frame=0;
renderer.material.SetTexture("_MainTex", tx[frame]);
}
}
}
}