/// <summary> /// Sets the color of clothing in the specified clothing slot to the specified color. /// </summary> /// <param name="slot"></param> /// <param name="newClothingColor"></param> public void UpdateClothingColor(ClothingSlot slot, Color newClothingColor) { ClothingSlotScript clothingSlotScript = transform.GetChild(ClothingObjects[slot]).gameObject.GetComponent <ClothingSlotScript>(); if (!clothingSlotScript.HasCustomMaterial) { clothingSlotScript.gameObject.GetComponent <Renderer>().sharedMaterial.color = newClothingColor; } else { Debug.Log("***Cannot change color of clothing object with custom material!"); } }
private void Awake() { GameObject objHandL, objHandR; ClothingObjects = new Dictionary <ClothingSlot, int>(); BodyObjects = new Dictionary <ClothingSlot, int>(); Transform_Hip = transform.Find("Player").Find("ROOT").Find("Hip_CONT").Find("Hip"); Transform_Head = Transform_Hip.Find("Spine").Find("Chest").Find("Neck").Find("Head").gameObject.transform; objHandL = new GameObject(name + "_Hand-L"); objHandR = new GameObject(name + "_Hand-R"); objHandL.transform.parent = Transform_Hip.Find("Spine").Find("Chest").Find("Collar_L").Find("Arm1_L").Find("Arm2_L").gameObject.transform; objHandR.transform.parent = Transform_Hip.Find("Spine").Find("Chest").Find("Collar_R").Find("Arm1_R").Find("Arm2_R").gameObject.transform; objHandL.transform.position = objHandL.transform.parent.position + (objHandL.transform.parent.right * -1 * GameMaster.Instance.CustomizationManager.Character.CharacterHandObjOffset); objHandR.transform.position = objHandR.transform.parent.position + (objHandR.transform.parent.right * -1 * GameMaster.Instance.CustomizationManager.Character.CharacterHandObjOffset); Transform_HandL = objHandL.transform; Transform_HandR = objHandR.transform; //Get & use a copy of the default body material (and color) MaterialBody = new Material(GameMaster.Instance.CustomizationManager.Character.MaterialBodyDefault); MaterialBody.name += " (copy)"; //Set up dictionaries & initialize all Clothing & Body placeholder objects for (int i = 0; i < transform.childCount; i++) { ClothingSlotScript clothingSlotScript = GetClothingSlotScript(i); if (clothingSlotScript != null) { clothingSlotScript.Initialize(this); if (!clothingSlotScript.IsBodyObject) { ClothingObjects.Add(clothingSlotScript.ClothingSlot, i); } else { BodyObjects.Add(clothingSlotScript.ClothingSlot, i); } } } //Remove all clothing (in this case, will remove/clear placeholder objects) UnsetAllClothing(); heldObject = new ObjectHeld(); }