So Im trying to make a script to animate my cursor (not a mouse cursor) also, im not using Gui Components at all. basically i have 32 different materials that are basically acting as a sprite sheet for this cursor. and if the cursor is over something selectable, it will change the material of the cursor 32 times over the course of 2 seconds. I havent added the Time.deltaTime stuff yet because now every time i play my game, the cursor just shows up as a pink rectangle, which im assuming means it has no material attached to it whatsoever.
heres my code
using UnityEngine;
using System.Collections;
public class CursorAnimation : MonoBehaviour {
public Texture2D txCursor;
static Material c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17,
c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32;
Material[] c_array = new Material[]{c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32};
void Start()
{
c0 = Resources.Load ("mat_reticle", typeof(Material)) as Material;
c1 = Resources.Load ("mat_c1", typeof(Material)) as Material;
c2 = Resources.Load ("mat_c2", typeof(Material)) as Material;
c3 = Resources.Load ("mat_c3", typeof(Material)) as Material;
c4 = Resources.Load ("mat_c4", typeof(Material)) as Material;
c5 = Resources.Load ("mat_c5", typeof(Material)) as Material;
c6 = Resources.Load ("mat_c6", typeof(Material)) as Material;
c7 = Resources.Load ("mat_c7", typeof(Material)) as Material;
c8 = Resources.Load ("mat_c8", typeof(Material)) as Material;
c9 = Resources.Load ("mat_9", typeof(Material)) as Material;
c10 = Resources.Load ("mat_c10", typeof(Material)) as Material;
c11 = Resources.Load ("mat_c11", typeof(Material)) as Material;
c12 = Resources.Load ("mat_c12", typeof(Material)) as Material;
c13 = Resources.Load ("mat_c13", typeof(Material)) as Material;
c14 = Resources.Load ("mat_c14", typeof(Material)) as Material;
c15 = Resources.Load ("mat_c15", typeof(Material)) as Material;
c16 = Resources.Load ("mat_c16", typeof(Material)) as Material;
c17 = Resources.Load ("mat_c17", typeof(Material)) as Material;
c18 = Resources.Load ("mat_c18", typeof(Material)) as Material;
c19 = Resources.Load ("mat_c19", typeof(Material)) as Material;
c20 = Resources.Load ("mat_c20", typeof(Material)) as Material;
c21 = Resources.Load ("mat_c21", typeof(Material)) as Material;
c22 = Resources.Load ("mat_c22", typeof(Material)) as Material;
c23 = Resources.Load ("mat_c23", typeof(Material)) as Material;
c24 = Resources.Load ("mat_c24", typeof(Material)) as Material;
c25 = Resources.Load ("mat_c25", typeof(Material)) as Material;
c26 = Resources.Load ("mat_c26", typeof(Material)) as Material;
c27 = Resources.Load ("mat_c27", typeof(Material)) as Material;
c28 = Resources.Load ("mat_c28", typeof(Material)) as Material;
c29 = Resources.Load ("mat_c29", typeof(Material)) as Material;
c30 = Resources.Load ("mat_c30", typeof(Material)) as Material;
c31 = Resources.Load ("mat_c31", typeof(Material)) as Material;
c32 = Resources.Load ("mat_c32", typeof(Material)) as Material;
}
public void animateCursor()
{
int spot = 0;
for (int x = 0; x < c_array.Length; x++){
GetComponent<Renderer> ().material = c_array [spot];
spot ++;
}
if (spot >= c_array.Length)
spot = 0;
}
}