private void AddCharacterButtons() { for (int i = 0; i < 8; i++) { GameObject go = new GameObject(); Analysis1CharacterButton button = go.AddComponent <Analysis1CharacterButton>(); button.Create(topButtonsNormalSprite[i], topButtonsDownSprite[i]); if (i < 4) { Vector3 v = topButtonstLeftPoint.position; v.x = topButtonstLeftPoint.position.x + (i * 1.1f) % 4; button.transform.position = v; } else { Vector3 v = topButtonstRightPoint.position; v.x = topButtonstRightPoint.position.x + (i * 1f) % 4; button.transform.position = v; } button.index = i; button.onClick = CharacterButtonOnClick; characterButtons.Add(button); objectsForDestroy.Add(go); } }
private void CharacterButtonOnClick(Analysis1CharacterButton button) { if (isStarted) { for (int i = 0; i < characterButtons.Count; i++) { if (i == button.index) { activeCharaterButtonIndex = i; } else { characterButtons[i].SetIsNormal(); } } BeginGame(); } }