public static bool ChangeSettingHairAcsColorPrefix(int parts, ChaControl __instance) { int HairAcsColorNum = __instance.GetHairAcsColorNum(parts); if (HairAcsColorNum == 0) { return(false); } ChaCustomHairComponent customHairComponent = __instance.GetCustomHairComponent(parts); if (null == customHairComponent) { return(false); } for (int i = 0; i < customHairComponent.rendAccessory.Length; i++) { for (int j = 0; j < HairAcsColorNum; j++) { if (customHairComponent.rendAccessory[i] == null) //Added null check { return(false); } } } return(true); }
public static bool ChangeSettingHairAcsColor(int parts, ChaControl __instance) { int hairAcsColorNum = __instance.GetHairAcsColorNum(parts); if (hairAcsColorNum == 0) { return(false); } ChaCustomHairComponent customHairComponent = __instance.GetCustomHairComponent(parts); if (null == customHairComponent) { return(false); } int[] array = new int[] { ChaShader._Color, ChaShader._Color2, ChaShader._Color3 }; ChaFileHair hair = __instance.chaFile.custom.hair; for (int i = 0; i < customHairComponent.rendAccessory.Length; i++) { for (int j = 0; j < hairAcsColorNum; j++) { if (1f > hair.parts[parts].acsColor[j].a) { hair.parts[parts].acsColor[j] = new Color(hair.parts[parts].acsColor[j].r, hair.parts[parts].acsColor[j].g, hair.parts[parts].acsColor[j].b, 1f); } if (customHairComponent.rendAccessory[i] != null) //Added null check { customHairComponent.rendAccessory[i].material.SetColor(array[j], hair.parts[parts].acsColor[j]); } } } return(false); }