Пример #1
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);
        }