private void OnGenderDropdownValueChanged(int selectedIndex) { SelectedGenderIndex = (byte)selectedIndex; UmaRace race = GameInstance.Singleton.UmaRaces[SelectedRaceIndex]; UmaRaceGender gender = race.genders[SelectedGenderIndex]; UmaModel.CacheUmaAvatar.ChangeRace(gender.raceData.raceName); UmaModel.CacheUmaAvatar.BuildCharacter(true); // Setup customizable slots GenericUtils.RemoveChildren(customizeSlotContainer); UmaCustomizableSlot[] slots = gender.customizableSlots; SelectedSlots = new byte[slots.Length]; for (byte i = 0; i < slots.Length; ++i) { UIUmaCustomizeSlotDropdown uiSlot = Instantiate(prefabCustomizeSlotDropdown); uiSlot.Setup(this, i); uiSlot.transform.SetParent(customizeSlotContainer); uiSlot.transform.localScale = Vector3.one; } // Setup color options GenericUtils.RemoveChildren(colorOptionContainer); SelectedColors = new byte[race.colorTables.Length]; for (byte i = 0; i < race.colorTables.Length; ++i) { UIUmaColorDropdown uiColor = Instantiate(prefabColorDropdown); uiColor.Setup(this, i); uiColor.transform.SetParent(colorOptionContainer); uiColor.transform.localScale = Vector3.one; } ApplyAvatar(); StartCoroutine(SetupDnas()); }
private void OnRaceDropdownValueChanged(int selectedIndex) { SelectedRaceIndex = (byte)selectedIndex; if (genderDropdown != null) { genderDropdown.onValueChanged.RemoveListener(OnGenderDropdownValueChanged); genderDropdown.options = new List <DropdownWrapper.OptionData>(); List <DropdownWrapper.OptionData> dropdownOptions = new List <DropdownWrapper.OptionData>(); UmaRace race = GameInstance.Singleton.UmaRaces[selectedIndex]; UmaRaceGender[] genders = race.genders; foreach (UmaRaceGender gender in genders) { dropdownOptions.Add(new DropdownWrapper.OptionData() { text = gender.name, }); } // Switch dropdown genderDropdown.options = dropdownOptions; OnGenderDropdownValueChanged(0); genderDropdown.onValueChanged.AddListener(OnGenderDropdownValueChanged); } }
IEnumerator ApplyUmaAvatarRoutine(UmaAvatarData avatarData) { int i; UmaRace race = CurrentGameInstance.UmaRaces[avatarData.raceIndex]; UmaRaceGender gender = race.genders[avatarData.genderIndex]; CacheUmaAvatar.ChangeRace(gender.raceData.raceName); yield return(null); // Set character hair, beard, eyebrows (or other things up to your settings) if (avatarData.slots != null) { Dictionary <string, List <UMATextRecipe> > recipes = CacheUmaAvatar.AvailableRecipes; string slotName; for (i = 0; i < gender.customizableSlots.Length; ++i) { if (i >= avatarData.slots.Length) { break; } slotName = gender.customizableSlots[i].name; CacheUmaAvatar.SetSlot(recipes[slotName][avatarData.slots[i]]); } } // Set skin color, eyes color, hair color (or other things up to your settings) if (avatarData.colors != null) { SharedColorTable colorTable; for (i = 0; i < race.colorTables.Length; ++i) { if (i >= avatarData.colors.Length) { break; } colorTable = race.colorTables[i]; CacheUmaAvatar.SetColor(colorTable.sharedColorName, colorTable.colors[avatarData.colors[i]]); } } // Set equip items if it is already set if (tempEquipWeapons != null) { SetEquipWeapons(tempEquipWeapons); } if (tempEquipItems != null) { SetEquipItems(tempEquipItems); } // Update avatar CacheUmaAvatar.BuildCharacter(true); CacheUmaAvatar.ForceUpdate(true, true, true); yield return(null); // Set character dna if (avatarData.dnas != null) { Dictionary <string, DnaSetter> dnas = null; while (dnas == null || dnas.Count == 0) { dnas = CacheUmaAvatar.GetDNA(); yield return(null); } List <string> dnaNames = new List <string>(dnas.Keys); dnaNames.Sort(); string dnaName; for (i = 0; i < dnaNames.Count; ++i) { if (i >= avatarData.dnas.Length) { break; } dnaName = dnaNames[i]; dnas[dnaName].Set(avatarData.dnas[i] * 0.01f); } } // Update avatar after set dna CacheUmaAvatar.ForceUpdate(true, false, false); }