private void FillHairAvatars() { if (currAvatarId == -1) { return; } PlayerCreationAvatar currAvatar = _avatars[currAvatarId]; foreach (PlayerCreationAvatar avatar in _hairAvatars) { avatar.SetFace(currAvatar.faceImg.sprite, currSkinColor); avatar.SetHair(currAvatar.hairImg.sprite); } }
IEnumerator Start() { AppManager.I.Player = null; // Remove current player _avatars = GetUICategoryObj(CategoryType.Avatar).GetComponentsInChildren <PlayerCreationAvatar>(true); _avatarBts = GetUICategoryObj(CategoryType.Avatar).GetComponentsInChildren <UIButton>(true); _hairColorBts = GetUICategoryObj(CategoryType.HairColor).GetComponentsInChildren <UIButton>(true); hairColors = new Color[_hairColorBts.Length]; for (int i = 0; i < _hairColorBts.Length; i++) { hairColors[i] = _hairColorBts[i].Bt.image.color; } UIButton[] bts = GetUICategoryObj(CategoryType.SkinColor).GetComponentsInChildren <UIButton>(true); skinColors = new Color[bts.Length]; for (int i = 0; i < bts.Length; i++) { skinColors[i] = bts[i].Bt.image.color; bts[i].BtToggleOffColor = bts[i].Bt.image.color; } bts = GetUICategoryObj(CategoryType.BgColor).GetComponentsInChildren <UIButton>(true); bgColors = new Color[bts.Length]; for (int i = 0; i < bts.Length; i++) { bgColors[i] = bts[i].Bt.image.color; bts[i].BtToggleOffColor = bts[i].Bt.image.color; } // Create hair avatars _hairAvatars = new PlayerCreationAvatar[_hairColorBts.Length]; for (int i = 0; i < _hairColorBts.Length; ++i) { UIButton bt = _hairColorBts[i]; PlayerCreationAvatar avatar = Instantiate(_avatars[0], bt.transform.parent, false); avatar.SetHairColor(bt.Bt.image.color); Destroy(bt.gameObject); _hairColorBts[i] = avatar.GetComponent <UIButton>(); _hairAvatars[i] = avatar; } selectionStepOffsetY = StartupOffsetY / (Categories.Length - 1f); CategoriesContainer.SetAnchoredPosY(StartupOffsetY); for (var i = 0; i < Categories.Length; ++i) { //Categories[i].gameObject.SetActive(i == 0); Categories[i].gameObject.SetActive(false); } BtContinue.gameObject.SetActive(false); BgColorCategory.gameObject.SetActive(false); AgeCategory.gameObject.SetActive(false); GenderCategory.gameObject.SetActive(true); // Initialize categories (wait) yield return(null); foreach (PlayerCreationUICategory cat in Categories) { cat.Init(); } BgColorCategory.Init(); AgeCategory.Init(); GenderCategory.Init(); // Listeners BtContinue.Bt.onClick.AddListener(OnContinue); foreach (PlayerCreationUICategory cat in Categories) { cat.OnSelect += OnSelectCategory; cat.OnDeselectAll += OnDeselectAllInCategory; } BgColorCategory.OnSelect += OnSelectCategory; BgColorCategory.OnDeselectAll += OnDeselectAllInCategory; GenderCategory.OnSelect += OnSelectCategory; GenderCategory.OnDeselectAll += OnDeselectAllInCategory; AgeCategory.OnSelect += OnSelectCategory; AgeCategory.OnDeselectAll += OnDeselectAllInCategory; SwitchState(State, true); playAudioDescription(State, 0); }