Пример #1
0
        private bool TryGetMapping(Mesh mesh, out MaterialSlotsDictionary mapping)
        {
            if (!materialSlots.TryGetValue(mesh, out mapping))
            {
                Debug.LogWarning($"No material mappings given for mesh '{mesh.name}' please add them to the materialSlotSetup '{name}'.");
                return(false);
            }

            return(true);
        }
Пример #2
0
        private Material[] ApplyMaterialToArray(Material[] materialArray, MaterialSlotType slotType, Material newMaterial, MaterialSlotsDictionary mapping)
        {
            if (!mapping.TryGetValue(slotType, out var materialIndex))
            {
                Debug.LogWarning($"Material cannot be applied. Slot type '{slotType}' is not defined in mapping of given mesh.");
                return(materialArray);
            }

            if (materialIndex >= materialArray.Length)
            {
                Array.Resize(ref materialArray, materialIndex + 1);
            }

            materialArray[materialIndex] = newMaterial;

            return(materialArray);
        }