/// <summary>
        /// Attempts to override declared <see cref="DefaultShaderProperties"/> from the current first render material.
        /// </summary>
        protected virtual ShaderProperty[] TransferDefaultShaderProperties()
        {
            var materials = GetRenderMaterials();

            if (materials == null || materials.Length == 0 || !materials[0])
            {
                return(DefaultShaderProperties);
            }
            var properties = new List <ShaderProperty>();

            foreach (var defaultProperty in DefaultShaderProperties)
            {
                var property = new ShaderProperty(defaultProperty);
                if (materials[0].HasProperty(property.Name))
                {
                    property.SetValue(materials[0].GetProperty(property.Type, property.Name));
                }
                properties.Add(property);
            }
            return(properties.ToArray());
        }
Exemple #2
0
        /// <summary>
        /// Returns <see cref="DefaultShaderProperties"/> overrided by the current first render material and state existing properties.
        /// </summary>
        protected virtual ShaderProperty[] GetOverridedShaderProperties()
        {
            var material   = GetRenderMaterial();
            var properties = new List <ShaderProperty>();

            foreach (var defaultProperty in DefaultShaderProperties)
            {
                var property = default(ShaderProperty);
                if (state != null && state.ShaderProperties.Any(p => p.Name == defaultProperty.Name))
                {
                    property = new ShaderProperty(state.ShaderProperties.First(p => p.Name == defaultProperty.Name));
                }
                else
                {
                    property = new ShaderProperty(defaultProperty);
                    if (material && material.HasProperty(property.Name))
                    {
                        property.SetValue(material.GetProperty(property.Type, property.Name));
                    }
                }
                properties.Add(property);
            }
            return(properties.ToArray());
        }