Exemple #1
0
        private void ShaderFeatureInfoGUI(AssetsConfig.ShaderInfo si, AssetsConfig.ShaderFeature sf, ref bool featureDirty)
        {
            bool hasFeature    = si.shaderFeatures.Exists((x) => { return(sf.name == x); });
            bool newHasFeature = GUILayout.Toggle(hasFeature, sf.name, GUILayout.MaxWidth(160));

            if (newHasFeature)
            {
                shaderFeatures.Add(sf.name);
            }
            if (hasFeature != newHasFeature)
            {
                featureDirty = true;
            }
        }
Exemple #2
0
        private void ShaderInfoGUI(AssetsConfig ac)
        {
            ac.shaderInfoFolder = EditorGUILayout.Foldout(ac.shaderInfoFolder, "Shader Info");
            if (ac.shaderInfoFolder)
            {
                EditorGUI.indentLevel++;

                for (int i = 0; i < ac.ShaderInfos.Count; ++i)
                {
                    AssetsConfig.ShaderInfo si = ac.ShaderInfos[i];
                    si.folder = EditorGUILayout.Foldout(si.folder, si.shader != null ? si.shader.name : "empty");
                    if (si.folder)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button("Delete", GUILayout.MaxWidth(80)))
                        {
                            ac.ShaderInfos.RemoveAt(i);
                        }
                        if (GUILayout.Button("Clear", GUILayout.MaxWidth(80)))
                        {
                            si.shaderFeatures.Clear();
                        }
                        EditorGUILayout.EndHorizontal();
                        si.shader = EditorGUILayout.ObjectField(si.shader, typeof(Shader), false, GUILayout.MaxWidth(160)) as Shader;
                        bool featureDirty = false;
                        shaderFeatures.Clear();

                        var it = groupedShaderFeatures.GetEnumerator();
                        while (it.MoveNext())
                        {
                            var kvp = it.Current;
                            EditorGUILayout.LabelField(kvp.Key);
                            EditorGUI.indentLevel++;
                            var sfList = kvp.Value;
                            for (int j = 0; j < sfList.Count; j += 3)
                            {
                                EditorGUILayout.BeginHorizontal();
                                AssetsConfig.ShaderFeature sf = sfList[j];
                                ShaderFeatureInfoGUI(si, sf, ref featureDirty);
                                if (j + 1 < sfList.Count)
                                {
                                    sf = sfList[j + 1];
                                    ShaderFeatureInfoGUI(si, sf, ref featureDirty);
                                    if (j + 2 < sfList.Count)
                                    {
                                        sf = sfList[j + 2];
                                        ShaderFeatureInfoGUI(si, sf, ref featureDirty);
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            EditorGUI.indentLevel--;
                            EditorGUILayout.Space();
                        }
                        if (featureDirty)
                        {
                            si.shaderFeatures.Clear();
                            si.shaderFeatures.AddRange(shaderFeatures);
                        }
                    }
                }
                EditorGUI.indentLevel--;
                if (GUILayout.Button("Add Shader Config", GUILayout.MaxWidth(180)))
                {
                    ac.ShaderInfos.Add(new AssetsConfig.ShaderInfo());
                }
                if (GUILayout.Button("Sort Shader Features", GUILayout.MaxWidth(180)))
                {
                    List <string> shaderFeatures = new List <string>();
                    for (int i = 0; i < ac.ShaderInfos.Count; ++i)
                    {
                        AssetsConfig.ShaderInfo si = ac.ShaderInfos[i];
                        if (si.shader != null)
                        {
                            shaderFeatures.Clear();
                            for (int j = 0; j < ac.ShaderFeatures.Count; ++j)
                            {
                                AssetsConfig.ShaderFeature sf = ac.ShaderFeatures[j];
                                bool hasFeature = si.shaderFeatures.Exists((x) => { return(sf.name == x); });
                                if (hasFeature)
                                {
                                    shaderFeatures.Add(sf.name);
                                }
                            }
                            si.shaderFeatures.Clear();
                            si.shaderFeatures.AddRange(shaderFeatures);
                        }
                    }
                }
            }
        }