public void SetDirection(Vector2 direction) { if (Direction == direction) { return; } Direction = direction; if (Direction == Vector2.zero) { Parts.ForEach(i => i.SetActive(true)); Shadows.ForEach(i => i.SetActive(true)); Parts[0].transform.localPosition = Shadows[0].transform.localPosition = new Vector3(0, -1.25f); Parts[1].transform.localPosition = Shadows[1].transform.localPosition = new Vector3(0, 1.25f); Parts[2].transform.localPosition = Shadows[2].transform.localPosition = new Vector3(-1.5f, 0); Parts[3].transform.localPosition = Shadows[3].transform.localPosition = new Vector3(1.5f, 0); return; } Parts.ForEach(i => i.transform.localPosition = Vector3.zero); Shadows.ForEach(i => i.transform.localPosition = Vector3.zero); int index; if (direction == Vector2.left) { index = 2; } else if (direction == Vector2.right) { index = 3; } else if (direction == Vector2.up) { index = 1; } else if (direction == Vector2.down) { index = 0; } else { throw new NotSupportedException(); } for (var i = 0; i < Parts.Count; i++) { Parts[i].SetActive(i == index); Shadows[i].SetActive(i == index); } }