Ejemplo n.º 1
0
        void ShowMenu(CheckResult result)
        {
            if (s_IntValues == null)
            {
                s_IntValues = new Dictionary <Check, int[]>();
            }

            if (!s_IntValues.ContainsKey(result.check))
            {
                int   count  = result.check.ResolutionActions.Length;
                int[] values = new int[count];
                for (int i = 0; i < count; i++)
                {
                    values[i] = i;
                }
                s_IntValues.Add(result.check, values);
            }

            result.resolutionActionIndex = EditorGUILayout.IntPopup(result.resolutionActionIndex, result.check.ResolutionActions, s_IntValues[result.check], EditorStyles.toolbarDropDown, GUILayout.Width(128));
        }
        public override void Resolve(CheckResult result)
        {
            if (s_DefaultMaterial == null)
            {
                var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                s_DefaultMaterial = cube.GetComponent <Renderer>().sharedMaterial;
                Object.DestroyImmediate(cube);
            }

            switch (result.resolutionActionIndex)
            {
            default:
                var renderer = (result.mainObject as GameObject).GetComponent <Renderer>();

                for (int i = 0; i < renderer.sharedMaterials.Length; i++)
                {
                    if (renderer.sharedMaterials[i] == null)
                    {
                        renderer.materials[i] = s_DefaultMaterial;
                    }
                }
                break;
            }
        }
Ejemplo n.º 3
0
 public abstract void Resolve(CheckResult result);
 public override void Resolve(CheckResult result)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 5
0
        private void OnGUI()
        {
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.Height(22)))
            {
                if (GUILayout.Button("Check", EditorStyles.toolbarButton))
                {
                    PerformChecks();
                }
                if (GUILayout.Button("", EditorStyles.toolbarPopup))
                {
                    Rect        r    = new Rect(0, 0, 16, 20);
                    GenericMenu menu = new GenericMenu();
                    foreach (Check check in s_CheckStates.Keys)
                    {
                        menu.AddItem(new GUIContent(check.name), s_CheckStates[check], () => SetCheckState(check, !s_CheckStates[check]));
                    }
                    menu.DropDown(r);
                }

                if (GUILayout.Button("Resolve", EditorStyles.toolbarButton))
                {
                    Resolve();
                }

                GUILayout.FlexibleSpace();

                filterString = EditorGUILayout.DelayedTextField(filterString, EditorStyles.toolbarSearchField, GUILayout.Width(180));

                showIgnored = GUILayout.Toggle(showIgnored, "Ignored", EditorStyles.toolbarButton);
                showNotice  = GUILayout.Toggle(showNotice, new GUIContent(m_Results.Where(o => o.result == CheckResult.Result.Notice).Count().ToString(), CheckResult.GetIcon(CheckResult.Result.Notice)), EditorStyles.toolbarButton);
                showWarning = GUILayout.Toggle(showWarning, new GUIContent(m_Results.Where(o => o.result == CheckResult.Result.Warning).Count().ToString(), CheckResult.GetIcon(CheckResult.Result.Warning)), EditorStyles.toolbarButton);
                showError   = GUILayout.Toggle(showError, new GUIContent(m_Results.Where(o => o.result == CheckResult.Result.Failed).Count().ToString(), CheckResult.GetIcon(CheckResult.Result.Failed)), EditorStyles.toolbarButton);
            }
            using (new GUILayout.VerticalScope())
            {
                GUI.backgroundColor = Color.white * 1.3f;
                using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    SortButton("Check Type", SortMode.CheckType, GUILayout.Width(128));
                    SortButton("Object", SortMode.ObjectName, GUILayout.Width(128));
                    SortButton("Message", SortMode.Message, GUILayout.ExpandWidth(true));
                    SortButton("Resolution", SortMode.Resolution, GUILayout.Width(128));
                    if (showIgnored)
                    {
                        SortButton("Ignored", SortMode.Ignored, GUILayout.Width(64));
                    }
                    GUILayout.Space(12);
                }

                Scroll = GUILayout.BeginScrollView(Scroll, false, true);

                if (m_Results != null && m_Results.Count > 0)
                {
                    bool odd = true;
                    foreach (var result in m_Results)
                    {
                        if (!showIgnored && IsIgnored(result) || result.mainObject == null)
                        {
                            continue;
                        }

                        if (result.result == CheckResult.Result.Notice && !showNotice)
                        {
                            continue;
                        }

                        if (result.result == CheckResult.Result.Warning && !showWarning)
                        {
                            continue;
                        }

                        if (result.result == CheckResult.Result.Failed && !showError)
                        {
                            continue;
                        }

                        if (!string.IsNullOrEmpty(filterString) && !result.message.text.Contains(filterString))
                        {
                            continue;
                        }

                        GUI.backgroundColor = Color.white * (odd ? 0.9f : 0.8f);
                        odd = !odd;

                        using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
                        {
                            EditorGUI.BeginDisabledGroup(showIgnored && IsIgnored(result));

                            GUILayout.Label(result.check.name, Styles.line, GUILayout.Width(128));
                            if (GUILayout.Button(result.mainObject != null? result.mainObject.name : "Null", Styles.line, GUILayout.Width(128)))
                            {
                                Selection.activeObject = result.mainObject;
                            }
                            GUILayout.Label(result.message, Styles.line, GUILayout.ExpandWidth(true));
                            ShowMenu(result);

                            EditorGUI.EndDisabledGroup();

                            if (showIgnored)
                            {
                                GUILayout.Space(18);
                                EditorGUI.BeginChangeCheck();
                                var ignored = GUILayout.Toggle(IsIgnored(result), "", EditorStyles.toggle, GUILayout.Width(24));
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SetIgnored(result, ignored);
                                }
                                GUILayout.Space(18);
                            }
                        }
                    }
                }
                else
                {
                    GUILayout.Label("No Results");
                }
                GUI.backgroundColor = Color.white;

                GUILayout.FlexibleSpace();
                GUILayout.EndScrollView();
            }
        }