コード例 #1
0
        /// <summary>
        /// Populate the ItemType dropdown for switching between displaying various types of items on a character
        /// </summary>
        protected void PopulateItemTypeDropdown(ChaControl chaControl)
        {
            ItemTypeDropDown.onValueChanged.RemoveAllListeners();
            ItemTypeDropDown.onValueChanged.AddListener(value => ChangeItemType(value, chaControl));
            ItemTypeDropDown.options.Clear();
            ItemTypeDropDown.options.Add(new Dropdown.OptionData("Body"));
            ItemTypeDropDown.Set(0);
            ItemTypeDropDown.captionText.text = "Body";

            for (var i = 0; i < chaControl.objClothes.Length; i++)
            {
                if (chaControl.objClothes[i] != null && chaControl.objClothes[i].GetComponentInChildren <ChaClothesComponent>() != null)
                {
                    ItemTypeDropDown.options.Add(new Dropdown.OptionData($"Clothes {ClothesIndexToString(i)}"));
                }
            }

            for (var i = 0; i < chaControl.objHair.Length; i++)
            {
                if (chaControl.objHair[i] != null && chaControl.objHair[i].GetComponent <ChaCustomHairComponent>() != null)
                {
                    ItemTypeDropDown.options.Add(new Dropdown.OptionData($"Hair {HairIndexToString(i)}"));
                }
            }

            var accessories = MaterialEditorPlugin.GetAcccessoryIndices(chaControl).ToList();

            accessories.Sort();
            for (var i = 0; i < accessories.Count; i++)
            {
                ItemTypeDropDown.options.Add(new Dropdown.OptionData($"Accessory {AccessoryIndexToString(accessories[i])}"));
            }
        }