示例#1
0
        public void LoadSettings()
        {
            string name      = MaterialBuffer.material.name;
            bool   firstOpen = !EditorPref.Has(name + "-Material");

            MaterialBuffer.options["ShowDefault"] = firstOpen ? true : EditorPref.Get <int>("ExtendedMaterial-ShowDefault").ToBool();
            MaterialBuffer.options["ShowPreview"] = firstOpen ? true : EditorPref.Get <int>("ExtendedMaterial-ShowPreview").ToBool();
            MaterialBuffer.options["ShaderUnity"] = EditorPref.Get <int>(name + "-ShaderUnity").ToBool();
            MaterialBuffer.options["ShaderGPU"]   = EditorPref.Get <int>(name + "-ShaderGPU").ToBool();
            MaterialBuffer.options["Properties"]  = EditorPref.Get <int>(name + "-Properties").ToBool();
            MaterialBuffer.options["Material"]    = firstOpen ? true : EditorPref.Get <int>(name + "-Material").ToBool();
            int shaderIndex = 0;
            int passIndex   = 0;

            foreach (SubShader subShader in MaterialBuffer.active.subShaders)
            {
                shaderIndex += 1;
                string shaderHash = "Sub" + shaderIndex;
                MaterialBuffer.options[shaderHash]          = firstOpen ? true : EditorPref.Get <int>(name + "-" + shaderHash).ToBool();
                MaterialBuffer.options[shaderHash + "Tags"] = EditorPref.Get <int>(name + "-" + shaderHash + "Tags").ToBool();
                MaterialBuffer.options[shaderHash + "Fog"]  = EditorPref.Get <int>(name + "-" + shaderHash + "Fog").ToBool();
                foreach (var item in subShader.passes)
                {
                    passIndex      += 1;
                    item.Value.name = item.Value.name;
                    string passHash = "Pass" + passIndex;
                    MaterialBuffer.options[passHash]          = firstOpen ? true : EditorPref.Get <int>(name + "-" + passHash).ToBool();
                    MaterialBuffer.options[passHash + "Tags"] = EditorPref.Get <int>(name + "-" + passHash + "Tags").ToBool();
                    MaterialBuffer.options[passHash + "Fog"]  = EditorPref.Get <int>(name + "-" + passHash + "Fog").ToBool();
                }
            }
        }
示例#2
0
        public void DrawBreakdown()
        {
            string breakdown = "StateBehaviourEditor-ToggleBreakdown";
            var    alias     = "State-" + this.target.As <StateBehaviour>().alias;

            if (EditorPref.Has(breakdown))
            {
                StateBehaviourEditor.isVisible = !StateBehaviourEditor.isVisible;
                EditorPrefs.DeleteKey(breakdown);
            }
            StateTable table = this.GetTable();

            if ((this.showAll || StateBehaviourEditor.isVisible) && table != null)
            {
                var            matchingOnRows  = table.table.Where(x => x.target == this.target).FirstOrDefault();
                var            matchingOffRows = table.tableOff.Where(x => x.target == this.target).FirstOrDefault();
                StateRowData[] onRows          = new StateRowData[0];
                StateRowData[] offRows         = new StateRowData[0];
                bool           hasOnData       = matchingOnRows != null;
                if (hasOnData)
                {
                    onRows    = matchingOnRows.requirements;
                    offRows   = matchingOffRows.requirements;
                    hasOnData = onRows.Select(x => x.data).First().Where(x => x.requireOn || x.requireOff).FirstOrDefault() != null;
                }
                this.BeginArea();
                EditorGUILayout.BeginHorizontal();
                if (hasOnData)
                {
                    var container = EditorStyles.helpBox.FixedWidth(Screen.width / 2 - 23).Padding(20, 20, 8, 8);
                    EditorGUILayout.BeginVertical(container, GUILayout.MinHeight(this.height));
                    for (int index = 0; index < onRows.Length; ++index)
                    {
                        string title = index < 1 ? "<b>ENABLED</b> if" : "<b>OR</b> if";
                        this.DrawState(onRows, index, title);
                    }
                    EditorGUILayout.EndVertical();
                    this.height = EditorUI.foldoutChanged ? 0 : this.height.Max(GUILayoutUtility.GetLastRect().height);
                    EditorGUILayout.BeginVertical(container, GUILayout.MinHeight(this.height));
                    if (table.advanced)
                    {
                        bool hasOffData = offRows.Select(x => x.data).First().Where(x => x.requireOn || x.requireOff).FirstOrDefault() != null;
                        if (!hasOffData)
                        {
                            string phrase = "Never turns off!".ToUpper();
                            phrase.DrawHelp("Warning");
                        }
                        else
                        {
                            for (int index = 0; index < offRows.Length; ++index)
                            {
                                string title = index < 1 ? "<b>DISABLED</b> if" : "<b>OR</b> if";
                                this.DrawState(offRows, index, title);
                            }
                        }
                    }
                    else
                    {
                        string header = "<b>DISABLED</b> if";
                        if (header.ToLabel().DrawFoldout(alias + "-Disabled", EditorStyles.foldout.RichText(true)))
                        {
                            string phrase = "<color=" + this.nameColor + ">@EXTERNAL</color><i> is </i><color=" + this.offColor + "><b>OFF</b></color>";
                            phrase.ToLabel().DrawLabel(this.labelStyle);
                            if (onRows.SelectMany(x => x.data).ToList().Exists(x => x.name != "@External" && (x.requireOn || x.requireOff)))
                            {
                                for (int index = 0; index < onRows.Length; ++index)
                                {
                                    string title = "<b>OR</b> if";
                                    this.DrawState(onRows, index, title, true);
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                    this.height = EditorUI.foldoutChanged ? 0 : this.height.Max(GUILayoutUtility.GetLastRect().height);
                }
                else
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    string phrase = ("Always <b><color=" + this.onColor + ">ENABLED</color></b>").ToUpper();
                    phrase.ToLabel().DrawLabel(this.labelStyle.Alignment("MiddleCenter"));
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();
                Rect area = GUILayoutUtility.GetLastRect();
                if (!area.IsEmpty())
                {
                    if (Proxy.IsRepainting())
                    {
                        this.breakdownArea = area;
                    }
                    if (area.Clicked(1))
                    {
                        this.DrawBreakdownMenu();
                    }
                    if (Event.current.shift && area.Clicked(0))
                    {
                        StateBehaviourEditor.isVisible = !StateBehaviourEditor.isVisible;
                    }
                }
                if (Proxy.IsRepainting() && !this.breakdownArea.IsEmpty())
                {
                    this.breakdownVisible = this.breakdownArea.InInspectorWindow();
                }
            }
        }