GetShader() private method

private GetShader ( ) : Shader
return UnityEngine.Shader
        internal override bool HasModified()
        {
            if (base.HasModified())
            {
                return(true);
            }
            ShaderImporter shaderImporter = this.target as ShaderImporter;

            if (shaderImporter == null)
            {
                return(false);
            }
            Shader shader = shaderImporter.GetShader();

            if (shader == null)
            {
                return(false);
            }
            int propertyCount = ShaderUtil.GetPropertyCount(shader);

            for (int i = 0; i < propertyCount; i++)
            {
                string propertyName = ShaderUtil.GetPropertyName(shader, i);
                for (int j = 0; j < this.propertyNames.Count; j++)
                {
                    if (this.propertyNames[j] == propertyName && this.textures[j] != shaderImporter.GetDefaultTexture(propertyName))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        internal override void ResetValues()
        {
            base.ResetValues();
            this.propertyNames = new List <string>();
            this.displayNames  = new List <string>();
            this.textures      = new List <Texture>();
            this.dimensions    = new List <TextureDimension>();
            ShaderImporter shaderImporter = this.target as ShaderImporter;

            if (shaderImporter == null)
            {
                return;
            }
            Shader shader = shaderImporter.GetShader();

            if (shader == null)
            {
                return;
            }
            int propertyCount = ShaderUtil.GetPropertyCount(shader);

            for (int i = 0; i < propertyCount; i++)
            {
                if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                {
                    string  propertyName        = ShaderUtil.GetPropertyName(shader, i);
                    string  propertyDescription = ShaderUtil.GetPropertyDescription(shader, i);
                    Texture defaultTexture      = shaderImporter.GetDefaultTexture(propertyName);
                    this.propertyNames.Add(propertyName);
                    this.displayNames.Add(propertyDescription);
                    this.textures.Add(defaultTexture);
                    this.dimensions.Add(ShaderUtil.GetTexDim(shader, i));
                }
            }
        }
        internal override bool HasModified()
        {
            if (base.HasModified())
            {
                return(true);
            }
            ShaderImporter target = this.target as ShaderImporter;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return(false);
            }
            Shader shader = target.GetShader();

            if ((UnityEngine.Object)shader == (UnityEngine.Object)null)
            {
                return(false);
            }
            int propertyCount = ShaderUtil.GetPropertyCount(shader);

            for (int propertyIdx = 0; propertyIdx < propertyCount; ++propertyIdx)
            {
                string propertyName = ShaderUtil.GetPropertyName(shader, propertyIdx);
                for (int index = 0; index < this.propertyNames.Count; ++index)
                {
                    if (this.propertyNames[index] == propertyName && (UnityEngine.Object) this.textures[index] != (UnityEngine.Object)target.GetDefaultTexture(propertyName))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        internal override void ResetValues()
        {
            base.ResetValues();
            this.propertyNames = new List <string>();
            this.displayNames  = new List <string>();
            this.textures      = new List <Texture>();
            this.dimensions    = new List <ShaderUtil.ShaderPropertyTexDim>();
            ShaderImporter target = this.target as ShaderImporter;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return;
            }
            Shader shader = target.GetShader();

            if ((UnityEngine.Object)shader == (UnityEngine.Object)null)
            {
                return;
            }
            int propertyCount = ShaderUtil.GetPropertyCount(shader);

            for (int propertyIdx = 0; propertyIdx < propertyCount; ++propertyIdx)
            {
                if (ShaderUtil.GetPropertyType(shader, propertyIdx) == ShaderUtil.ShaderPropertyType.TexEnv)
                {
                    string  propertyName        = ShaderUtil.GetPropertyName(shader, propertyIdx);
                    string  propertyDescription = ShaderUtil.GetPropertyDescription(shader, propertyIdx);
                    Texture defaultTexture      = target.GetDefaultTexture(propertyName);
                    this.propertyNames.Add(propertyName);
                    this.displayNames.Add(propertyDescription);
                    this.textures.Add(defaultTexture);
                    this.dimensions.Add(ShaderUtil.GetTexDim(shader, propertyIdx));
                }
            }
        }
        public override bool HasModified()
        {
            bool result;

            if (base.HasModified())
            {
                result = true;
            }
            else
            {
                ShaderImporter shaderImporter = base.target as ShaderImporter;
                if (shaderImporter == null)
                {
                    result = false;
                }
                else
                {
                    Shader shader = shaderImporter.GetShader();
                    if (shader == null)
                    {
                        result = false;
                    }
                    else
                    {
                        int propertyCount = ShaderUtil.GetPropertyCount(shader);
                        for (int i = 0; i < propertyCount; i++)
                        {
                            string propertyName = ShaderUtil.GetPropertyName(shader, i);
                            for (int j = 0; j < this.m_Properties.Count; j++)
                            {
                                if (this.m_Properties[j].propertyName == propertyName)
                                {
                                    Texture y = (!this.m_Properties[j].modifiable) ? shaderImporter.GetNonModifiableTexture(propertyName) : shaderImporter.GetDefaultTexture(propertyName);
                                    if (this.m_Properties[j].texture != y)
                                    {
                                        result = true;
                                        return(result);
                                    }
                                }
                            }
                        }
                        result = false;
                    }
                }
            }
            return(result);
        }
Beispiel #6
0
        public override void OnInspectorGUI()
        {
            ShaderImporter target = base.target as ShaderImporter;

            if (target != null)
            {
                Shader shader = target.GetShader();
                if (shader != null)
                {
                    if (GetNumberOfTextures(shader) != this.propertyNames.Count)
                    {
                        this.ResetValues();
                    }
                    this.ShowDefaultTextures();
                    base.ApplyRevertGUI();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            ShaderImporter shaderImporter = base.target as ShaderImporter;

            if (!(shaderImporter == null))
            {
                Shader shader = shaderImporter.GetShader();
                if (!(shader == null))
                {
                    if (ShaderImporterInspector.GetNumberOfTextures(shader) != this.m_Properties.Count)
                    {
                        this.ResetValues();
                    }
                    this.ShowTextures();
                    base.ApplyRevertGUI();
                }
            }
        }
        protected override void ResetValues()
        {
            base.ResetValues();
            this.m_Properties.Clear();
            ShaderImporter shaderImporter = base.target as ShaderImporter;

            if (!(shaderImporter == null))
            {
                Shader shader = shaderImporter.GetShader();
                if (!(shader == null))
                {
                    int propertyCount = ShaderUtil.GetPropertyCount(shader);
                    for (int i = 0; i < propertyCount; i++)
                    {
                        if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                        {
                            string  propertyName        = ShaderUtil.GetPropertyName(shader, i);
                            string  propertyDescription = ShaderUtil.GetPropertyDescription(shader, i);
                            bool    flag = !ShaderUtil.IsShaderPropertyNonModifiableTexureProperty(shader, i);
                            Texture texture;
                            if (!flag)
                            {
                                texture = shaderImporter.GetNonModifiableTexture(propertyName);
                            }
                            else
                            {
                                texture = shaderImporter.GetDefaultTexture(propertyName);
                            }
                            ShaderImporterInspector.TextureProp item = new ShaderImporterInspector.TextureProp
                            {
                                propertyName = propertyName,
                                texture      = texture,
                                dimension    = ShaderUtil.GetTexDim(shader, i),
                                displayName  = propertyDescription,
                                modifiable   = flag
                            };
                            this.m_Properties.Add(item);
                        }
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            ShaderImporter target = this.target as ShaderImporter;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return;
            }
            Shader shader = target.GetShader();

            if ((UnityEngine.Object)shader == (UnityEngine.Object)null)
            {
                return;
            }
            if (ShaderImporterInspector.GetNumberOfTextures(shader) != this.propertyNames.Count)
            {
                this.ResetValues();
            }
            this.ShowDefaultTextures();
            this.ApplyRevertGUI();
        }