public void SetColor(int playerid, SheetAnimation.PlayerColor color) { this.playerid = playerid; SpriteRenderer spriteR = gameObject.AddComponent <SpriteRenderer>(); spriteR.sprite = Resources.Load <Sprite>("Menu/Cursor_" + color.ToString().ToUpper()[0]); buttons = FindObjectsOfType <Button>(); spriteR.sortingOrder = 5; levelBounds = FindObjectOfType <LevelBounds>(); }
// Use this for initialization void Start() { baseMoveSpeed = MoveSpeed; _rigid = GetComponent <Rigidbody2D>(); SpriteR = GetComponent <SpriteRenderer>(); SAnimation = GetComponent <SheetAnimation>(); Pcolor = GetComponent <PlayerHit>().color; overlay = GetComponent <SpriteOverlay>(); if (currentAxis == 0 && InputManager.GetAxis("Horizontal", playerID) != 0) { ChangeAxis(); } /* * GameObject clones = new GameObject("test clones"); * testClone = new GameObject(); * testClone.transform.parent = clones.transform; * testClone.AddComponent<SpriteRenderer>().sprite = SpriteR.sprite; * testClone.GetComponent<SpriteRenderer>().sortingOrder = SpriteR.sortingOrder - 1; * testClone.transform.localScale = new Vector3(testClone.transform.localScale.x * 0.3f, testClone.transform.localScale.y * 0.3f, testClone.transform.localScale.z); * * testClone2 = new GameObject(); * testClone2.transform.parent = clones.transform; * testClone2.AddComponent<SpriteRenderer>().sprite = SpriteR.sprite; * testClone2.GetComponent<SpriteRenderer>().flipY = true; * testClone2.GetComponent<SpriteRenderer>().sortingOrder = SpriteR.sortingOrder - 2; * testClone2.GetComponent<SpriteRenderer>().color = Color.yellow; * testClone2.transform.localScale = new Vector3(testClone2.transform.localScale.x * 0.3f, testClone2.transform.localScale.y * 0.3f, testClone2.transform.localScale.z); * * for (int i = 0; i < testClones.Length; i++) * { * testClones[i] = new GameObject(); * testClones[i].transform.parent = clones.transform; * testClones[i].AddComponent<SpriteRenderer>().sprite = SpriteR.sprite; * testClones[i].GetComponent<SpriteRenderer>().flipY = true; * testClones[i].GetComponent<SpriteRenderer>().sortingOrder = SpriteR.sortingOrder - 3; * testClones[i].GetComponent<SpriteRenderer>().color = Color.magenta; * testClones[i].transform.localScale = new Vector3(testClones[i].transform.localScale.x * 0.3f, testClones[i].transform.localScale.y * 0.3f + ((float)i / 25f), testClones[i].transform.localScale.z); * } */ }
public void SetSprite(string path, SheetAnimation.PlayerColor color) { spriteName = path; SAnimation.PlayAnimationCustom(path, GetComponent <PlayerHit>().color, 0); }