Example #1
0
        public void ApplyMaterial(MaterialSelectionDictionary materialSelectionDictionary)
        {
            var meshFilter = GetComponentInChildren <MeshFilter>();

            if (meshFilter == null)
            {
                Debug.LogWarning("Cannot apply materials because roomElement '" + gameObject.name + "' has no meshFilters as children.");
                return;
            }

            var meshes            = meshFilter.sharedMesh;
            var meshRendererArray = meshFilter.GetComponent <MeshRenderer>();

            ExtendableRoom.MaterialSlotSetup.ApplyRandomMaterials(meshes, meshRendererArray, materialSelectionDictionary);
        }
Example #2
0
        private Dictionary <MaterialSlotType, Material> PickRandomMaterials(MaterialSelectionDictionary materialChoices)
        {
            Dictionary <MaterialSlotType, Material> pickedMaterials = new Dictionary <MaterialSlotType, Material>();

            foreach (var kvp in materialChoices)
            {
                if (kvp.Value == null || kvp.Value.Count == 0)
                {
                    Debug.LogWarning("Material Choice for side '" + kvp.Key + "' cannot be applied. List is null or empty.");
                    continue;
                }

                pickedMaterials[kvp.Key] = kvp.Value.PickRandom();
            }

            return(pickedMaterials);
        }
        public override SerializableDictionary <MaterialSlotType, MaterialListWrapper> Clone()
        {
            var newDictionary = new MaterialSelectionDictionary();

            return(CloneInto(newDictionary));
        }
Example #4
0
 public Material[] ApplyRandomMaterialsToArray(Mesh mesh, Material[] materialArray, MaterialSelectionDictionary materialChoices)
 {
     return(ApplyMaterialsToArray(mesh, materialArray, PickRandomMaterials(materialChoices)));
 }
Example #5
0
 public void ApplyRandomMaterials(Mesh mesh, MeshRenderer meshRenderer, MaterialSelectionDictionary materialChoices)
 {
     ApplyMaterials(mesh, meshRenderer, PickRandomMaterials(materialChoices));
 }