void AnimatAllVariations() { //Find the tile sprite type array by using string reflection (should only happen at awake or if tile sprite type changes) Sprite[] tileXx = (Sprite[])tile.GetType().GetField("tile" + tile.tileSprite).GetValue(tile); if (tileXx.Length > 1) { tileX = tileXx; currentTileSprite = tile.tileSprite; Invoke("Animate", speed); } }
void ChangeCurrentSprite() { //Fix error event error if (preCurrentSprite != currentSprite) { currentSprite = preCurrentSprite; Sprite[] arr = (Sprite[])tile.GetType().GetField("tile" + tile.SpriteNumberToName(currentSprite)).GetValue(tile); if (arr != null) { currentArraySize = arr.Length; } } }