private void PopulateListAccessory() { var chaControl = MakerAPI.GetCharacterControl(); int coordinateIndex = MaterialEditorPlugin.GetCharaController(chaControl).CurrentCoordinateIndex; var chaAccessoryComponent = AccessoriesApi.GetAccessory(MakerAPI.GetCharacterControl(), AccessoriesApi.SelectedMakerAccSlot); PopulateList(chaAccessoryComponent?.gameObject, ObjectType.Accessory, coordinateIndex: coordinateIndex, slot: AccessoriesApi.SelectedMakerAccSlot); }
/// <summary> /// Checks if the specified accessory is a hair accessory /// </summary> public bool IsHairAccessory(int slot) { try { return(AccessoriesApi.GetAccessory(ChaControl, slot)?.gameObject.GetComponent <ChaCustomHairComponent>() != null); } catch { return(false); } }
/// <summary> /// Checks if the specified accessory has length transforms (trfLength in the ChaCustomHairComponent MonoBehavior) /// </summary> public bool HasLengthTransforms() { var chaCustomHairComponent = AccessoriesApi.GetAccessory(ChaControl, AccessoriesApi.SelectedMakerAccSlot)?.gameObject.GetComponent <ChaCustomHairComponent>(); if (chaCustomHairComponent != null) { foreach (Transform transform in chaCustomHairComponent.trfLength) { if (transform != null) { return(true); } } } return(false); }
/// <summary> /// Checks if the specified accessory is a hair accessory and has accessory parts (rendAccessory in the ChaCustomHairComponent MonoBehavior) /// </summary> public bool HasAccessoryPart() { var chaCustomHairComponent = AccessoriesApi.GetAccessory(ChaControl, AccessoriesApi.SelectedMakerAccSlot)?.gameObject.GetComponent <ChaCustomHairComponent>(); if (chaCustomHairComponent != null) { foreach (Renderer renderer in chaCustomHairComponent.rendAccessory) { if (renderer != null) { return(true); } } } return(false); }
/// <summary> /// Sets up the visibility and values for the current slot /// </summary> internal static void InitCurrentSlot(HairAccessoryController controller, bool hairAccessory) { if (!MakerAPI.InsideAndLoaded) { return; } if (hairAccessory) { ColorMatchToggle.SetSelectedValue(controller.GetColorMatch(), false); HairGlossToggle.SetSelectedValue(controller.GetHairGloss(), false); OutlineColorPicker.SetSelectedValue(controller.GetOutlineColor(), false); AccessoryColorPicker.SetSelectedValue(controller.GetAccessoryColor(), false); HairLengthSlider.SetSelectedValue(controller.GetHairLength(), false); ColorMatchToggle.Control.Visible.OnNext(true); HairGlossToggle.Control.Visible.OnNext(true); OutlineColorPicker.Control.Visible.OnNext(!controller.GetColorMatch()); AccessoryColorPicker.Control.Visible.OnNext(controller.HasAccessoryPart()); HairLengthSlider.Control.Visible.OnNext(controller.HasLengthTransforms()); if (controller.GetColorMatch(AccessoriesApi.SelectedMakerAccSlot)) { HideAccColors(); } else { ShowAccColors(true); } } else { ColorMatchToggle.SetSelectedValue(ColorMatchDefault, false); HairGlossToggle.SetSelectedValue(HairGlossDefault, false); OutlineColorPicker.SetSelectedValue(OutlineColorDefault, false); AccessoryColorPicker.SetSelectedValue(AccessoryColorDefault, false); HairGlossToggle.Control.Visible.OnNext(false); ColorMatchToggle.Control.Visible.OnNext(false); OutlineColorPicker.Control.Visible.OnNext(false); AccessoryColorPicker.Control.Visible.OnNext(false); HairLengthSlider.Control.Visible.OnNext(false); ShowAccColors(AccessoriesApi.GetAccessory(controller.ChaControl, AccessoriesApi.SelectedMakerAccSlot) != null); } }
/// <summary> /// Updates the specified hair accessory /// </summary> public void UpdateAccessory(int slot, bool updateCharacter = true) { if (!IsHairAccessory(slot)) { return; } ChaAccessoryComponent chaAccessoryComponent = AccessoriesApi.GetAccessory(ChaControl, slot); ChaCustomHairComponent chaCustomHairComponent = chaAccessoryComponent?.gameObject.GetComponent <ChaCustomHairComponent>(); if (!HairAccessories.ContainsKey(CurrentCoordinateIndex)) { return; } if (!HairAccessories[CurrentCoordinateIndex].TryGetValue(slot, out var hairAccessoryInfo)) { return; } if (chaAccessoryComponent?.rendNormal == null) { return; } if (chaCustomHairComponent?.rendHair == null) { return; } if (updateCharacter && MakerAPI.InsideAndLoaded && hairAccessoryInfo.ColorMatch) { ChaCustom.CvsAccessory cvsAccessory = AccessoriesApi.GetCvsAccessory(slot); cvsAccessory.UpdateAcsColor01(ChaControl.chaFile.custom.hair.parts[0].baseColor); cvsAccessory.UpdateAcsColor02(ChaControl.chaFile.custom.hair.parts[0].startColor); cvsAccessory.UpdateAcsColor03(ChaControl.chaFile.custom.hair.parts[0].endColor); OutlineColorPicker.SetValue(slot, ChaControl.chaFile.custom.hair.parts[0].outlineColor, false); hairAccessoryInfo.OutlineColor = ChaControl.chaFile.custom.hair.parts[0].outlineColor; } else if (updateCharacter && !MakerAPI.InsideMaker) { foreach (Renderer renderer in chaCustomHairComponent.rendHair) { if (renderer == null) { continue; } if (renderer.material.HasProperty(ChaShader._Color)) { renderer.material.SetColor(ChaShader._Color, ChaControl.chaFile.custom.hair.parts[0].baseColor); } if (renderer.material.HasProperty(ChaShader._Color2)) { renderer.material.SetColor(ChaShader._Color2, ChaControl.chaFile.custom.hair.parts[0].startColor); } if (renderer.material.HasProperty(ChaShader._Color3)) { renderer.material.SetColor(ChaShader._Color3, ChaControl.chaFile.custom.hair.parts[0].endColor); } } } Texture2D texHairGloss = (Texture2D)AccessTools.Property(typeof(ChaControl), "texHairGloss").GetValue(ChaControl, null); foreach (Renderer renderer in chaCustomHairComponent.rendHair) { if (renderer == null) { continue; } if (renderer.material.HasProperty(ChaShader._HairGloss)) { var mt = renderer.material.GetTexture(ChaShader._MainTex); if (hairAccessoryInfo.HairGloss) { renderer.material.SetTexture(ChaShader._HairGloss, texHairGloss); } else { renderer.material.SetTexture(ChaShader._HairGloss, null); } Destroy(mt); } if (renderer.material.HasProperty(ChaShader._LineColor)) { if (hairAccessoryInfo.ColorMatch) { renderer.material.SetColor(ChaShader._LineColor, ChaControl.chaFile.custom.hair.parts[0].outlineColor); } else { renderer.material.SetColor(ChaShader._LineColor, hairAccessoryInfo.OutlineColor); } } } foreach (Renderer renderer in chaCustomHairComponent.rendAccessory) { if (renderer == null) { continue; } if (renderer.material.HasProperty(ChaShader._Color)) { renderer.material.SetColor(ChaShader._Color, hairAccessoryInfo.AccessoryColor); } if (renderer.material.HasProperty(ChaShader._Color2)) { renderer.material.SetColor(ChaShader._Color2, hairAccessoryInfo.AccessoryColor); } if (renderer.material.HasProperty(ChaShader._Color3)) { renderer.material.SetColor(ChaShader._Color3, hairAccessoryInfo.AccessoryColor); } } chaCustomHairComponent.lengthRate = hairAccessoryInfo.HairLength; }
/// <summary> /// Checks if the specified accessory is a hair accessory /// </summary> public bool IsHairAccessory(int slot) => AccessoriesApi.GetAccessory(ChaControl, slot)?.gameObject.GetComponent <ChaCustomHairComponent>() != null;
public static void UpdateAccessoryMoveFromInfo(int slotNo, ChaControl __instance) => RemoveNullParts(AccessoriesApi.GetAccessory(__instance, slotNo)?.gameObject?.GetComponent <ChaCustomHairComponent>());
internal void PopulateListAccessory() { var chaAccessoryComponent = AccessoriesApi.GetAccessory(MakerAPI.GetCharacterControl(), AccessoriesApi.SelectedMakerAccSlot); PopulateList(chaAccessoryComponent?.gameObject, slot: AccessoriesApi.SelectedMakerAccSlot); }
private IEnumerator LoadData(bool clothes, bool accessories, bool hair) { yield return(null); foreach (var property in RendererPropertyList) { if (property.ObjectType == ObjectType.Clothing && clothes && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in ChaControl.objClothes[property.Slot].GetComponentsInChildren <Renderer>()) { if (rend.NameFormatted() == property.RendererName) { SetRendererProperty(rend, property.Property, int.Parse(property.Value)); } } } else if (property.ObjectType == ObjectType.Accessory && accessories && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in AccessoriesApi.GetAccessory(ChaControl, property.Slot)?.gameObject.GetComponentsInChildren <Renderer>()) { if (rend.name == property.RendererName) { SetRendererProperty(rend, property.Property, int.Parse(property.Value)); } } } else if (property.ObjectType == ObjectType.Hair && hair) { foreach (var rend in ChaControl.objHair[property.Slot]?.gameObject.GetComponentsInChildren <Renderer>()) { if (rend.name == property.RendererName) { SetRendererProperty(rend, property.Property, int.Parse(property.Value)); } } } } foreach (var property in MaterialFloatPropertyList) { if (property.ObjectType == ObjectType.Clothing && clothes && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in ChaControl.objClothes[property.Slot].GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetFloatProperty(ChaControl.objClothes[property.Slot], mat, property.Property, property.Value); } } } } else if (property.ObjectType == ObjectType.Accessory && accessories && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in AccessoriesApi.GetAccessory(ChaControl, property.Slot)?.gameObject.GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetFloatProperty(AccessoriesApi.GetAccessory(ChaControl, property.Slot)?.gameObject, mat, property.Property, property.Value); } } } } else if (property.ObjectType == ObjectType.Hair && hair) { foreach (var rend in ChaControl.objHair[property.Slot]?.gameObject.GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetFloatProperty(ChaControl.objHair[property.Slot]?.gameObject, mat, property.Property, property.Value); } } } } } foreach (var property in MaterialColorPropertyList) { if (property.ObjectType == ObjectType.Clothing && clothes && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in ChaControl.objClothes[property.Slot].GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetColorProperty(ChaControl.objClothes[property.Slot], mat, property.Property, property.Value); } } } } else if (property.ObjectType == ObjectType.Accessory && accessories && property.CoordinateIndex == CurrentCoordinateIndex) { foreach (var rend in AccessoriesApi.GetAccessory(ChaControl, property.Slot)?.gameObject.GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetColorProperty(AccessoriesApi.GetAccessory(ChaControl, property.Slot)?.gameObject, mat, property.Property, property.Value); } } } } else if (property.ObjectType == ObjectType.Hair && hair) { foreach (var rend in ChaControl.objHair[property.Slot]?.gameObject.GetComponentsInChildren <Renderer>()) { foreach (var mat in rend.materials) { if (mat.NameFormatted() == property.MaterialName) { SetColorProperty(ChaControl.objHair[property.Slot]?.gameObject, mat, property.Property, property.Value); } } } } } }