private static void SetSkinColor(ChaControl chaControl, ColorMatchPart colorMatchPart, string file) { //get main tex Texture2D mainTexture = CommonLib.LoadAsset <Texture2D>(file, colorMatchPart.MainTex, false, string.Empty); if (mainTexture == null) { return; } //get color mask Texture2D colorMask = CommonLib.LoadAsset <Texture2D>(file, colorMatchPart.ColorMask, false, string.Empty); if (colorMask == null) { return; } //find the game object FindAssist findAssist = new FindAssist(); findAssist.Initialize(chaControl.objBody.transform); GameObject gameObject = findAssist.GetObjectFromName(colorMatchPart.Object); if (gameObject == null) { return; } if (!gameObject.GetComponent <Renderer>().material.HasProperty(ChaShader._MainTex)) { return; } var customTex = new CustomTextureControl(gameObject.transform); customTex.Initialize(file, colorMatchPart.Material, string.Empty, file, colorMatchPart.MaterialCreate, string.Empty, 2048, 2048); customTex.SetMainTexture(mainTexture); customTex.SetColor(ChaShader._Color, chaControl.chaFile.custom.body.skinMainColor); customTex.SetTexture(ChaShader._ColorMask, colorMask); customTex.SetColor(ChaShader._Color2, chaControl.chaFile.custom.body.skinSubColor); //set the new texture var newTex = customTex.RebuildTextureAndSetMaterial(); if (newTex == null) { return; } Material mat = gameObject.GetComponent <Renderer>().material; var mt = mat.GetTexture(ChaShader._MainTex); mat.SetTexture(ChaShader._MainTex, newTex); //Destroy the old texture to prevent memory leak Destroy(mt); }
private static void SetSkinGloss(ChaControl chaControl, ColorMatchPart colorMatchPart) { FindAssist findAssist = new FindAssist(); findAssist.Initialize(chaControl.objBody.transform); GameObject gameObject = findAssist.GetObjectFromName(colorMatchPart.Object); if (gameObject != null) { gameObject.GetComponent <Renderer>().material.SetFloat(ChaShader._SpecularPower, Mathf.Lerp(chaControl.chaFile.custom.body.skinGlossPower, 1f, chaControl.chaFile.status.skinTuyaRate)); } }
private static void SetLineVisibility(ChaControl chaControl, ColorMatchPart colorMatchPart) { FindAssist findAssist = new FindAssist(); findAssist.Initialize(chaControl.objBody.transform); GameObject gameObject = findAssist.GetObjectFromName(colorMatchPart.Object); if (gameObject != null) { gameObject.GetComponent <Renderer>().material.SetFloat(ChaShader._linetexon, chaControl.chaFile.custom.body.drawAddLine ? 1f : 0f); } }
private void SetLineVisibility(ColorMatchPart colorMatchPart) { #if KK || EC FindAssist findAssist = new FindAssist(); findAssist.Initialize(ChaControl.objBody.transform); GameObject go = findAssist.GetObjectFromName(colorMatchPart.Object); if (go != null) { go.GetComponent <Renderer>().material.SetFloat(ChaShader._linetexon, ChaControl.chaFile.custom.body.drawAddLine ? 1f : 0f); } #endif }
private void SetSkinGloss(ColorMatchPart colorMatchPart) { #if KK || EC || KKS FindAssist findAssist = new FindAssist(); findAssist.Initialize(ChaControl.objBody.transform); GameObject go = findAssist.GetObjectFromName(colorMatchPart.Object); if (go != null) { go.GetComponent <Renderer>().material.SetFloat(ChaShader._SpecularPower, Mathf.Lerp(ChaControl.chaFile.custom.body.skinGlossPower, 1f, ChaControl.chaFile.status.skinTuyaRate)); } #endif }
public BallsData(XContainer ballsXMLData) { if (ballsXMLData == null) { return; } BallsGUID = ballsXMLData.Element("guid")?.Value; DisplayName = ballsXMLData.Element("displayName")?.Value; File = ballsXMLData.Element("file")?.Value; Asset = ballsXMLData.Element("asset")?.Value; if (ballsXMLData.Element("allowRandom")?.Value.ToLower() == "false" || ballsXMLData.Element("allowRandom")?.Value.ToLower() == "0") { AllowRandom = false; } foreach (XElement colorMatch in ballsXMLData.Elements("colorMatch")) { ColorMatchPart part = new ColorMatchPart(colorMatch.Element("object")?.Value, colorMatch.Element("material")?.Value, colorMatch.Element("materialCreate")?.Value, colorMatch.Element("mainTex")?.Value, colorMatch.Element("colorMask")?.Value); if (part.Verify()) { ColorMatchList.Add(part); } } //These things can be null if the XML doesn't exist or empty strings if it does exist but is left blank //Set everything to null for easier checks BallsGUID = BallsGUID.IsNullOrWhiteSpace() ? null : BallsGUID; DisplayName = DisplayName.IsNullOrWhiteSpace() ? null : DisplayName; File = File.IsNullOrWhiteSpace() ? null : File; Asset = Asset.IsNullOrWhiteSpace() ? null : Asset; }
public BodyData(XContainer bodyXMLData) { if (bodyXMLData == null) { return; } BodyGUID = bodyXMLData.Element("guid")?.Value; DisplayName = bodyXMLData.Element("displayName")?.Value; if (bodyXMLData.Element("sex")?.Value.ToLower() == "female") { Sex = 1; } if (bodyXMLData.Element("allowRandom")?.Value.ToLower() == "false" || bodyXMLData.Element("allowRandom")?.Value.ToLower() == "0") { AllowRandom = false; } XElement oo_base = bodyXMLData.Element("oo_base"); if (oo_base != null) { OOBase = oo_base.Element("file")?.Value; if (Asset.IsNullOrWhiteSpace()) { Asset = oo_base.Element("asset")?.Value; } BodyMainTex = oo_base.Element("mainTex")?.Value; BodyColorMask = oo_base.Element("colorMask")?.Value; Normals = oo_base.Element("normals")?.Value; UncensorOverlay = oo_base.Element("uncensorOverlay")?.Value; UncensorUnderlay = oo_base.Element("uncensorUnderlay")?.Value; foreach (XElement parts in oo_base.Elements("additionalPart")) { string part = parts?.Value; if (!part.IsNullOrWhiteSpace()) { AdditionalParts.Add(part); } } foreach (XElement colorMatch in oo_base.Elements("colorMatch")) { ColorMatchPart part = new ColorMatchPart(colorMatch.Element("object")?.Value, colorMatch.Element("material")?.Value, colorMatch.Element("materialCreate")?.Value, colorMatch.Element("mainTex")?.Value, colorMatch.Element("colorMask")?.Value); if (part.Verify()) { ColorMatchList.Add(part); } } } XElement mm_base = bodyXMLData.Element("oo_base"); if (mm_base != null) { MMBase = mm_base.Element("mm_base")?.Value; BodyMaterial = mm_base.Element("material")?.Value; BodyMaterialCreate = mm_base.Element("materialCreate")?.Value; } //These things can be null if the XML doesn't exist or empty strings if it does exist but is left blank //Set everything to null/defaults for easier checks MMBase = MMBase.IsNullOrWhiteSpace() ? Defaults.MMBase : MMBase; OOBase = OOBase.IsNullOrWhiteSpace() ? Defaults.OOBase : OOBase; BodyGUID = BodyGUID.IsNullOrWhiteSpace() ? null : BodyGUID; DisplayName = DisplayName.IsNullOrWhiteSpace() ? BodyGUID : DisplayName; Normals = Normals.IsNullOrWhiteSpace() ? Defaults.Normals : Normals; BodyMainTex = BodyMainTex.IsNullOrWhiteSpace() ? Defaults.BodyMainTex : BodyMainTex; BodyColorMask = BodyColorMask.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.BodyColorMaskMale : Defaults.BodyColorMaskFemale : BodyColorMask; Asset = Asset.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.AssetMale : Defaults.AssetFemale : Asset; BodyMaterial = BodyMaterial.IsNullOrWhiteSpace() ? Sex == 0 ? Defaults.BodyMaterialMale : Defaults.BodyMaterialFemale : BodyMaterial; BodyMaterialCreate = BodyMaterialCreate.IsNullOrWhiteSpace() ? Defaults.BodyMaterialCreate : BodyMaterialCreate; }