public void SetDropdownValue(CharacterSettings.CustomisationClass currentSetting) { // Find the index of the setting in the dropdown list which matches the currentSetting int settingIndex = Dropdown.options.FindIndex(option => option.text == currentSetting.SelectedName); if (settingIndex != -1) { // Make sure FindIndex is successful before changing value Dropdown.value = settingIndex; } else { Logger.LogWarning($"Unable to find index of {currentSetting}! Using default", Category.Character); Dropdown.value = 0; } // if (thisCustomisations.CanColour) // { //currentCharacter.HairColor = "#" + ColorUtility.ToHtmlStringRGB(UnityEngine.Random.ColorHSV()); Color setColor = Color.black; ColorUtility.TryParseHtmlString(currentSetting.Colour, out setColor); color = setColor; SelectionColourImage.color = setColor; RelatedSpriteRenderer.SetColor(setColor); // } Refresh(); }
public CharacterSettings.CustomisationClass Serialise() { var newcurrentSetting = new CharacterSettings.CustomisationClass(); // if (thisCustomisations.CanColour) // { newcurrentSetting.Colour = "#" + ColorUtility.ToHtmlStringRGB(color); // } newcurrentSetting.SelectedName = Dropdown.options[Dropdown.value].text; return(newcurrentSetting); }