Пример #1
0
        internal static void RemoveMaterialFromTable(Material materialSource, Texture2D texture)
        {
            var mt  = SlotBlendModes.MaterialTable;
            var key = new MaterialTexturePair {
                material = materialSource, texture2D = texture
            };

            mt.Remove(key);
        }
Пример #2
0
        internal static MaterialWithRefcount GetExistingMaterialFor(Material materialSource, Texture2D texture)
        {
            if (materialSource == null || texture == null)
            {
                return(null);
            }

            var mt = SlotBlendModes.MaterialTable;
            MaterialWithRefcount matWithRefcount;
            var key = new MaterialTexturePair {
                material = materialSource, texture2D = texture
            };

            if (!mt.TryGetValue(key, out matWithRefcount))
            {
                return(null);
            }
            return(matWithRefcount);
        }
Пример #3
0
        internal static Material GetMaterialFor(Material materialSource, Texture2D texture)
        {
            if (materialSource == null || texture == null)
            {
                return(null);
            }
            Dictionary <MaterialTexturePair, Material> dictionary = MaterialTable;
            MaterialTexturePair materialTexturePair = default(MaterialTexturePair);

            materialTexturePair.material  = materialSource;
            materialTexturePair.texture2D = texture;
            MaterialTexturePair key = materialTexturePair;

            if (!dictionary.TryGetValue(key, out Material value))
            {
                value             = new Material(materialSource);
                value.name        = "(Clone)" + texture.name + "-" + materialSource.name;
                value.mainTexture = texture;
                dictionary[key]   = value;
            }
            return(value);
        }
Пример #4
0
        internal static Material GetMaterialFor(Material materialSource, Texture2D texture)
        {
            if (materialSource == null || texture == null)
            {
                return(null);
            }

            var      mt = SlotBlendModes.MaterialTable;
            Material m;
            var      key = new MaterialTexturePair {
                material = materialSource, texture2D = texture
            };

            if (!mt.TryGetValue(key, out m))
            {
                m             = new Material(materialSource);
                m.name        = "(Clone)" + texture.name + "-" + materialSource.name;
                m.mainTexture = texture;
                mt[key]       = m;
            }

            return(m);
        }