Пример #1
0
        private void DrawPropFix()
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Member Resolution", EditorStyling.Skinned.boldTitle);
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("For each type in which unresolved field or property references were found, you will see a section below.\n\nThe left hand side of the list shows all fields and properties that could not be resolved.\n\nThe right hand side is where you can provide the new name.\nYou can also leave it blank in which case the reference will be removed from the AI.", SharedStyles.BuiltIn.wrappedText);
            EditorGUILayout.EndVertical();

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, "Box");

            var labelContent = new GUIContent();

            foreach (var type in _memberResolution)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUILayout.BeginHorizontal(SharedStyles.BuiltIn.listItemHeader);
                labelContent.text    = type.typeName.fullTypeName;
                labelContent.tooltip = type.typeName.assemblyName;
                EditorGUILayout.LabelField(labelContent);
                EditorGUILayout.EndHorizontal();

                labelContent.tooltip = string.Empty;
                foreach (var member in type.unresolvedMembers)
                {
                    EditorGUILayout.BeginHorizontal();
                    labelContent.text = member.unresolvedName;
                    EditorGUILayout.LabelField(labelContent);

                    EditorGUILayout.LabelField("->", GUILayout.Width(40f));

                    if (member.resolvedName != null)
                    {
                        labelContent.text = member.resolvedName;
                    }
                    else
                    {
                        labelContent.text = "?";
                    }

                    EditorGUILayout.LabelField(labelContent);

                    if (GUILayout.Button("...", EditorStyling.Skinned.fixedButton))
                    {
                        var screenPos = EditorGUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                        GenericSelectorWindow.Show <string>(
                            screenPos,
                            "Select Member",
                            type.potentialReplacements,
                            RenderListItem,
                            MatchItem,
                            true,
                            false,
                            m =>
                        {
                            if (m.Length > 0)
                            {
                                member.resolvedName = m[0];
                            }
                            else
                            {
                                member.resolvedName = null;
                            }

                            this.Repaint();
                        });

                        this.Repaint();
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Back"))
            {
                if (_typeResolution.Length == 0)
                {
                    ToStart();
                }
                else
                {
                    _scrollPos = Vector2.zero;
                    _step      = Step.Types;
                }
            }

            if (GUILayout.Button("Proceed"))
            {
                _working = true;

                EditorAsync.Execute(
                    () =>
                {
                    _mismatchResolution = _utility.IdentifyMismatchedMembers();
                    if (_mismatchResolution.Length > 0)
                    {
                        _step = Step.Mismatch;
                    }
                    else
                    {
                        _status = _utility.GetStatus();
                        _step   = Step.Summary;
                    }
                },
                    () =>
                {
                    _scrollPos = Vector2.zero;
                    EndWork();
                });
            }

            EditorGUILayout.EndHorizontal();
        }
Пример #2
0
        private void DrawMismatchFix()
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Mismatch Resolution", EditorStyling.Skinned.boldTitle);
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("For each type in which a mismatch between a field's or property's type and the actual value was found, you will see a section below.\n\nThe left hand side of the list shows all fields and properties with mismatched values.\n\nThe right hand side is where you can provide a new value if applicable.\nYou can also leave it blank in which case the value will be reset to its default value.", SharedStyles.BuiltIn.wrappedText);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUIUtility.labelWidth = 100f;
            _utility.hideApexTypes      = EditorGUILayout.Toggle("Hide Apex types", _utility.hideApexTypes);
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, "Box");

            var labelContent = new GUIContent();

            foreach (var mm in _mismatchResolution)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUILayout.BeginHorizontal(SharedStyles.BuiltIn.listItemHeader);
                labelContent.text = mm.parentName;
                EditorGUILayout.LabelField(labelContent);
                EditorGUILayout.EndHorizontal();

                labelContent.tooltip = string.Empty;
                foreach (var member in mm.mismatchedMembers)
                {
                    EditorGUILayout.BeginHorizontal();
                    labelContent.text = member.item.name;
                    if (string.IsNullOrEmpty(labelContent.text))
                    {
                        labelContent.text = "Item";
                    }

                    EditorGUILayout.LabelField(labelContent);

                    labelContent.text = member.typeName;
                    EditorGUILayout.LabelField(labelContent);

                    if (member.isCorrectable)
                    {
                        EditorGUILayout.LabelField("->", GUILayout.Width(40f));

                        if (member.baseType.IsEnum)
                        {
                            var val = member.resolvedValue;
                            if (val == null)
                            {
                                var arr = Enum.GetValues(member.baseType);
                                if (arr.Length > 0)
                                {
                                    val = arr.GetValue(0);
                                }
                            }

                            if (val != null)
                            {
                                member.resolvedValue = EditorGUILayout.EnumPopup((Enum)val);
                            }
                        }
                        else
                        {
                            if (member.resolvedTypeName != null)
                            {
                                labelContent.text = member.resolvedTypeName.fullTypeName;
                            }
                            else
                            {
                                labelContent.text = "?";
                            }

                            EditorGUILayout.LabelField(labelContent);

                            if (GUILayout.Button("...", EditorStyling.Skinned.fixedButton))
                            {
                                var screenPos = EditorGUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                                GenericSelectorWindow.Show <TypeNameTokens>(
                                    screenPos,
                                    "Select Type",
                                    _utility.GetAvailableTypes(member.baseType),
                                    RenderListItem,
                                    MatchItem,
                                    true,
                                    false,
                                    t =>
                                {
                                    member.resolvedTypeName = t.Length > 0 ? t[0] : null;
                                    this.Repaint();
                                });

                                this.Repaint();
                            }
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Back"))
            {
                if (_memberResolution.Length > 0)
                {
                    _step = Step.Members;
                }
                else if (_typeResolution.Length > 0)
                {
                    _step = Step.Types;
                }
                else
                {
                    ToStart();
                }
            }

            if (GUILayout.Button("Proceed"))
            {
                _working = true;

                EditorAsync.Execute(
                    () => _utility.GetStatus(),
                    (rs) =>
                {
                    _status    = rs;
                    _scrollPos = Vector2.zero;
                    _step      = Step.Summary;

                    EndWork();
                });
            }

            EditorGUILayout.EndHorizontal();
        }
Пример #3
0
        private void DrawTypeFix()
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Type Resolution", EditorStyling.Skinned.boldTitle);
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("The left hand side of the list shows all types that could not be resolved.\n\nThe right hand side is where you can provide the new type name.\nYou can also leave it blank in which case the element will be removed from the AI.", SharedStyles.BuiltIn.wrappedText);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUIUtility.labelWidth = 100f;
            _utility.hideApexTypes      = EditorGUILayout.Toggle("Hide Apex types", _utility.hideApexTypes);
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, "Box");

            var labelContent = new GUIContent();

            foreach (var entry in _typeResolution)
            {
                EditorGUILayout.BeginHorizontal("Box");
                labelContent.text    = entry.unresolvedTypeName.fullTypeName;
                labelContent.tooltip = entry.unresolvedTypeName.assemblyName;
                EditorGUILayout.LabelField(labelContent);

                EditorGUILayout.LabelField("->", GUILayout.Width(40f));

                if (entry.resolvedTypeName != null)
                {
                    labelContent.text    = entry.resolvedTypeName.fullTypeName;
                    labelContent.tooltip = entry.resolvedTypeName.assemblyName;
                }
                else
                {
                    labelContent.text    = "?";
                    labelContent.tooltip = "Unresolved type";
                }

                EditorGUILayout.LabelField(labelContent);

                if (GUILayout.Button("...", EditorStyling.Skinned.fixedButton))
                {
                    var screenPos = EditorGUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                    GenericSelectorWindow.Show <TypeNameTokens>(
                        screenPos,
                        "Select Type",
                        _utility.GetAvailableTypes(entry.baseType),
                        RenderListItem,
                        MatchItem,
                        true,
                        false,
                        t =>
                    {
                        _utility.UpdateResolvedType(entry, t.Length > 0 ? t[0] : null);
                        this.Repaint();
                    });

                    this.Repaint();
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Back"))
            {
                ToStart();
            }

            if (GUILayout.Button("Proceed"))
            {
                _working = true;

                EditorAsync.Execute(
                    () =>
                {
                    _memberResolution = _utility.IdentifyUnresolvedMembers();
                    if (_memberResolution.Length > 0)
                    {
                        _step = Step.Members;
                    }
                    else
                    {
                        _mismatchResolution = _utility.IdentifyMismatchedMembers();
                        if (_mismatchResolution.Length > 0)
                        {
                            _step = Step.Mismatch;
                        }
                        else
                        {
                            _status = _utility.GetStatus();
                            _step   = Step.Summary;
                        }
                    }
                },
                    () =>
                {
                    _scrollPos = Vector2.zero;
                    EndWork();
                });
            }

            EditorGUILayout.EndHorizontal();
        }