Exemple #1
0
            public void SetGlobalValues(ShaderField info, object value)
            {
                bool isEnable = (bool)value;

                if (isEnable)
                {
                    Shader.EnableKeyword(info.ShaderFieldName);
                }
                else
                {
                    Shader.DisableKeyword(info.ShaderFieldName);
                }
            }
Exemple #2
0
            public void SetMaterial(ShaderField info, Material material, object value)
            {
                bool isEnable = (bool)value;

                if (isEnable)
                {
                    material.EnableKeyword(info.ShaderFieldName);
                }
                else
                {
                    material.DisableKeyword(info.ShaderFieldName);
                }
            }
Exemple #3
0
            public static bool TryCreate(ShaderField field, MaterialProperty[] properties, out IFieldDrawer drawer)
            {
                var materialProperty = ShaderDrawerHelper.PublicFindProperty(field.ShaderFieldName, properties);

                if (materialProperty != null)
                {
                    drawer = new StandardFieldDrawer(field, materialProperty);
                    return(true);
                }
                else
                {
                    drawer = default(IFieldDrawer);
                    return(false);
                }
            }
Exemple #4
0
            public void SetMaterial(ShaderField info, Material material, object value)
            {
                var vecto2 = (Vector2)value;

                material.SetVector(info.ShderFieldID, vecto2);
            }
Exemple #5
0
            public void SetMaterial(ShaderField info, Material material, object value)
            {
                var intValue = (int)value;

                material.SetInt(info.ShaderFieldName, intValue);
            }
Exemple #6
0
            public void SetGlobalValues(ShaderField info, object value)
            {
                int intValue = (int)value;

                Shader.SetGlobalInt(info.ShaderFieldName, intValue);
            }
Exemple #7
0
 public void SetMaterial(ShaderField info, Material material, object value)
 {
     material.SetMatrixArray(info.ShderFieldID, (Matrix4x4[])value);
 }
Exemple #8
0
 public void SetGlobalValues(ShaderField info, object value)
 {
     Shader.SetGlobalMatrixArray(info.ShderFieldID, (Matrix4x4[])value);
 }
Exemple #9
0
 public object GetValue(ShaderField info, Material material)
 {
     return(material.GetFloat(info.ShderFieldID));
 }
Exemple #10
0
 public void SetMaterial(ShaderField info, Material material, object value)
 {
     material.SetVectorArray(info.ShderFieldID, (Vector4[])value);
 }
Exemple #11
0
 public void SetGlobalValues(ShaderField info, object value)
 {
     Shader.SetGlobalVectorArray(info.ShderFieldID, (Vector4[])value);
 }
Exemple #12
0
            public void SetMaterial(ShaderField info, Material material, object value)
            {
                Vector3 vector3 = (Vector3)value;

                material.SetVector(info.ShderFieldID, vector3);
            }
Exemple #13
0
            public object GetValue(ShaderField info, Material material)
            {
                Vector4 value = material.GetVector(info.ShderFieldID);

                return(new Vector3(value.x, value.y, value.z));
            }
Exemple #14
0
            public void SetGlobalValues(ShaderField info, object value)
            {
                Vector3 vector3 = (Vector3)value;

                Shader.SetGlobalVector(info.ShderFieldID, vector3);
            }
Exemple #15
0
            public object GetGlobalValues(ShaderField info)
            {
                Vector4 value = Shader.GetGlobalVector(info.ShderFieldID);

                return(new Vector3(value.x, value.y, value.z));
            }
Exemple #16
0
 public void SetMaterial(ShaderField info, Material material, object value)
 {
     material.SetTextureScale(info.ShderFieldID, (Vector2)value);
 }
Exemple #17
0
 public object GetGlobalValues(ShaderField info)
 {
     return(Shader.GetGlobalMatrixArray(info.ShderFieldID));
 }
Exemple #18
0
 public void SetGlobalValues(ShaderField info, object value)
 {
     Shader.SetGlobalFloatArray(info.ShderFieldID, (float[])value);
 }
Exemple #19
0
 public object GetValue(ShaderField info, Material material)
 {
     return(material.GetMatrixArray(info.ShderFieldID));
 }
Exemple #20
0
 public void SetMaterial(ShaderField info, Material material, object value)
 {
     material.SetFloatArray(info.ShderFieldID, (float[])value);
 }
Exemple #21
0
 public object GetGlobalValues(ShaderField info)
 {
     return(Shader.GetGlobalInt(info.ShaderFieldName));
 }
Exemple #22
0
 public object GetGlobalValues(ShaderField info)
 {
     return(Shader.GetGlobalTexture(info.ShderFieldID));
 }
Exemple #23
0
 public object GetValue(ShaderField info, Material material)
 {
     return(material.GetInt(info.ShaderFieldName));
 }
Exemple #24
0
 public void SetGlobalValues(ShaderField info, object value)
 {
     Shader.SetGlobalTexture(info.ShderFieldID, (Texture)value);
 }
Exemple #25
0
 public object GetGlobalValues(ShaderField info)
 {
     return(Shader.IsKeywordEnabled(info.ShaderFieldName));
 }
Exemple #26
0
 public object GetGlobalValues(ShaderField info)
 {
     return(default(Vector2));
 }
Exemple #27
0
 public object GetValue(ShaderField info, Material material)
 {
     return(material.IsKeywordEnabled(info.ShaderFieldName));
 }
Exemple #28
0
 public void SetGlobalValues(ShaderField info, object value)
 {
 }
Exemple #29
0
        private static void InternalFind(Type type, ICollection <IShaderFieldGroup> parameters)
        {
            var fields = EnumerateFields(type);

            foreach (var field in fields)
            {
                string            name;
                ShaderFieldFormat format;
                Type   fieldType = field.FieldType;
                string fieldName = field.Name;

                var attributes = field.MemberInfo.GetCustomAttributes();

                foreach (var attribute in attributes)
                {
                    if (attribute is ObsoleteAttribute)
                    {
                        goto NextField;
                    }
                }

                foreach (var attribute in attributes)
                {
                    if (attribute is ShaderFieldBaseAttribute)
                    {
                        if (attribute is ShaderFieldAttribute)
                        {
                            var att = (ShaderFieldAttribute)attribute;
                            name = att.Name;

                            var customClass = fieldType.GetCustomAttribute <ShaderCustomFieldClassAttribute>();
                            if (customClass != null)
                            {
                                var methods = fieldType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                                foreach (var method in methods)
                                {
                                    var customMethod = method.GetCustomAttribute <ShaderCustomFieldMethodAttribute>();
                                    if (customMethod != null)
                                    {
                                        IShaderField customField = (IShaderField)method.Invoke(null, null);
                                        if (customField == null)
                                        {
                                            throw new ArgumentException("Custom method return null!" + method.ToString());
                                        }

                                        var parameter = new ShaderCustomField(name, att.Mask, field, customField);
                                        parameters.Add(parameter);
                                    }
                                }
                            }
                            else if (TryGetFormat(ref name, fieldType, out format))
                            {
                                var parameter = new ShaderField(name, att.Mask, format, field);
                                parameters.Add(parameter);
                            }
                        }
                        else if (attribute is ShaderFieldKeywordAttribute)
                        {
                            var att = (ShaderFieldKeywordAttribute)attribute;
                            if (typeof(bool) == fieldType)
                            {
                                ShaderKeyword parameter = new ShaderKeyword(att.Keyword, field, att.ShortName, att.Mask);
                                parameters.Add(parameter);
                            }
                        }
                        else if (attribute is ShaderFieldEnumKeywordAttribute)
                        {
                            var att = (ShaderFieldEnumKeywordAttribute)attribute;
                            if (typeof(Enum).IsAssignableFrom(fieldType))
                            {
                                var item = new ShaderEnumKeyword(att.Mask, field, att.Keywords);
                                parameters.Add(item);
                            }
                        }
                        else if (attribute is ShaderFieldMarkAttribute)
                        {
                            var att  = (ShaderFieldMarkAttribute)attribute;
                            var item = new ShaderFieldMark(att.Mask, field);
                            parameters.Add(item);
                        }

                        goto NextField;
                    }
                }

                var structAttribute = field.FieldType.GetCustomAttribute <ShaderFieldGroupAttribute>();
                if (structAttribute != null)
                {
                    var group = new ShaderFieldGroup(field, structAttribute.Mask);
                    InternalFind(fieldType, group.Children);
                    if (group.Children.Count > 0)
                    {
                        parameters.Add(group);
                    }
                    goto NextField;
                }

NextField:
                continue;
            }
        }
Exemple #30
0
 public object GetValue(ShaderField info, Material material)
 {
     return(material.GetTextureScale(info.ShderFieldID));
 }