/// <summary> /// Change all Material List on this game object the next/before material /// </summary> /// <param name="Next">true: next, false: before</param> public void SetAllMaterials(bool Next = true) { if (MatChanger && !Locked) { MatChanger.SetAllMaterials(Next); All_MaterialChangerIndex = MatChanger.AllIndex; //Update the Indexes } }
/// <summary> /// Set a Lock Material to the current item /// </summary> /// <param name="Locked_Material">if mat == null Will unlock the item</param> public void SetLockMaterial(Material Locked_Material) { if (MatChanger) //Check if is there a Material Changer component { if (Locked_Material) //if they have a lock material set it to the item { MatChanger.SetAllMaterials(Locked_Material); } else //If not reset to the first material on the set and Unlock the material { locked = false; MatChanger.AllIndex = All_MaterialChangerIndex; } } else //If the Items does NOT have Material Changer { if (ItemMeshes != null && ItemMeshes.Length > 0) { if (Locked_Material) //if they have a lock material set it to the item { for (int i = 0; i < ItemMeshes.Length; i++) { Material[] LockedSet = new Material[ItemMeshes[i].materials.Length]; for (int k = 0; k < LockedSet.Length; k++) { LockedSet[k] = Locked_Material; } ItemMeshes[i].materials = LockedSet; } } else //If not reset to the first material on the set and Unlock the material { locked = false; for (int i = 0; i < ItemMeshes.Length; i++) { ItemMeshes[i].materials = BaseMaterial[i]; } } } } if (ActiveMesh) { ActiveMesh.AllIndex = All_ActiveMeshIndex; } }
/// <summary> /// Set a Lock Material to the current item /// </summary> /// <param name="mat">if mat == null Will unlock the item</param> public void SetLockMaterial(Material mat) { if (MatChanger) //Check if is there a Material Changer component { if (mat) //if they have a lock material set it to the item { MatChanger.SetAllMaterials(mat); } else //If not reset to the first material on the set and Unlock the material { locked = false; MatChanger.AllIndex = All_MaterialChangerIndex; } } else //If the Items does NOT have Material Changer { Renderer RItem = GetComponentInChildren <Renderer>(); if (!RItem) { return; } if (mat) //if they have a lock material set it to the item { RItem.material = mat; } else //If not reset to the first material on the set and Unlock the material { locked = false; RItem.materials = SoloMaterial; } } if (ActiveMesh) { ActiveMesh.AllIndex = All_ActiveMeshIndex; } }