// Use this for initialization void Start() { CustomizationManager.instance.OnCostumeChanged.AddListener(CostumeChanged); CustomizationManager.instance.OnHairStyleChanged.AddListener(HairStyleChanged); CustomizationManager.instance.OnFaceChanged.AddListener(FaceChanged); // Find all sprite meshes attached to the player. This will avoid accessive GetComponent calls skeleton = PlayerMeshSkeleton.GetSkeleton(); // Update the player's costume CostumeChanged(); HairStyleChanged(); FaceChanged(); }
// Use this for initialization void Start() { CustomizationManager.instance.OnSkinChanged.AddListener(SetSkinSV); CustomizationManager.instance.OnCostumeChanged.AddListener(CostumeChanged); HSVRangeMin = CustomizationManager.instance.GetHSVRangeMin(); HSVRangeMax = CustomizationManager.instance.GetHSVRangeMax(); // Creates instances of the HSV and default sprite materials to be applied at runtime as needed. skinMaterial = new Material(Shader.Find("Custom/HSVRangeShader")); spriteMaterial = new Material(Shader.Find("Sprites/Default")); // Adjust HSV ranges skinMaterial.SetFloat("_HSVRangeMin", HSVRangeMin); skinMaterial.SetFloat("_HSVRangeMax", HSVRangeMax); // Find all sprite meshes attached to the player. This makes recoloring far easier. skeleton = PlayerMeshSkeleton.GetSkeleton(); // Gets a reference to the player's head head = skeleton.Find(h => h.name == "Head"); skinBodyParts.Add(head); // Determine the components that need to be recolored based on the costume. CostumeData costume = CustomizationManager.instance.GetCurrentCostume(); if (costume != null) { List <string> costumeTargets = costume.GetSkinTargets(); foreach (string s in costumeTargets) { AddSkinTarget(s); } } // Applies skin color SetSkinSV(); ApplySkinColorToTargets(); }