void SetupBlendshapes(CustomizeItemLibrary library) { if (!library.itemInstances[library.tempItemInd]) { return; } var skin = library.itemInstances[library.tempItemInd].GetComponentInChildren <SkinnedMeshRenderer>(); if (!skin) { return; } for (int i = 0; i < skin.sharedMesh.blendShapeCount; ++i) { var split = skin.sharedMesh.GetBlendShapeName(i).Split('_'); if (split[0] == blendshapePrefix) { library.bsSliders[i].ToggleShowHide(true); library.bsSliders[i].label1.text = split[split.Length - 1]; // library.bsSliders[i].slider1.value = skin.sharedMesh.GetBlendShapeFrameWeight(i, 0); } } for (int i = skin.sharedMesh.blendShapeCount; i < library.bsSliders.Count; ++i) { library.bsSliders[i].ToggleShowHide(false); } LayoutRebuilder.ForceRebuildLayoutImmediate(library.parent as RectTransform); }
void SetupColorOptions(CustomizeItemLibrary library) { colorPicker.ClearAndDisable(); if (!library.itemInstances[library.tempItemInd]) { return; } var mats = library.itemInstances[library.tempItemInd].GetComponentInChildren <Renderer>()?.materials; if (mats == null) { return; } for (int i = 0; i < mats.Length; ++i) { library.colorPickers[i].ToggleShowHide(true); library.colorPickers[i].image1.color = mats[i].color; library.colorPickers[i].label1.text = mats[i].name; } for (int i = mats.Length; i < library.colorPickers.Count; ++i) { library.colorPickers[i].ToggleShowHide(false); } }
public CustomizeItemLibrary GetLibrary(ItemTag type) { CustomizeItemLibrary library = null; itemLibraryDict.TryGetValue(type, out library); return(library); }
void OnSliderChange(CustomizeItemLibrary library) { int val = (int)library.optionUI.slider1.value; var item = library.items[val]; library.tempItemInd = val; customizeCharacter.MannequinEquipItem(library, item); UpdateOptionLabel(library, item); SetupColorOptions(library); SetupBlendshapes(library); colorPicker.ClearAndDisable(); }
void UpdateOptionLabel(CustomizeItemLibrary library, Item item) { library.optionUI.label1.text = item.prefab ? $"{library.optionType.ToString()} {library.optionUI.slider1.value + 1}" : $"No {library.optionType.ToString()}"; }
void OnBlendshapeSlider(CustomizeItemLibrary library, int bsInd) { float val = library.bsSliders[bsInd].slider1.value; customizeCharacter.MannequinSetBlendshapeWeight(library.items[library.tempItemInd], bsInd, val); }
void OnSwatchToggle(CustomizeItemLibrary library, int matInd) { colorPicker.SetColorOption(library.optionType, matInd, library.colorPickers[matInd].toggle1); }
public void MannequinEquipItem(CustomizeItemLibrary library, Item item) { library.itemInstances[library.tempItemInd] = mannequin.charEquip.EquipItem(item); }