Esempio n. 1
0
        protected override void DrawChangeableElements()
        {
            base.DrawChangeableElements();
            var myClass = target as TwoWayDataBinding;

            var evntGenericMenu = new GenericMenu();

            for (var index = 0; index < myClass.DstChangedEvents.Count; index++)
            {
                var dstEvent = myClass.DstChangedEvents[index];
                var index1   = index;
                evntGenericMenu.AddItem(new GUIContent(dstEvent), index == _eventIdx, () =>
                {
                    _eventIdx = index1;
                    UpdateSerializedProperties();
                });
            }

            var isSelectedDstEventValid = _eventIdx >= 0 && myClass.DstChangedEvents.Count > _eventIdx;

            if (!isSelectedDstEventValid)
            {
                EditorGUILayout.HelpBox("Destination Changed Event is no longer valid consider fixing it!", MessageType.Error);
            }

            EditorGUILayoutHelper.PopGenericMenuAsDropDown(new GUIContent("Destination Changed Event"), new GUIContent(isSelectedDstEventValid ? myClass.DstChangedEvents[_eventIdx] : "Empty"), evntGenericMenu, contentColor: isSelectedDstEventValid ? (Color?)null : Color.red);
        }
Esempio n. 2
0
 public static bool ToggleGroup(string label, bool toggle, DrawDelegate draw)
 {
     toggle = EditorGUILayout.BeginToggleGroup(label, toggle);
     EditorGUILayoutHelper.Indent(draw);
     EditorGUILayout.EndToggleGroup();
     return(toggle);
 }
Esempio n. 3
0
 private static void DrawInfoMessage()
 {
     using (new GUILayoutHelper.Vertical(DropdownStyle.NoPadding))
     {
         EditorGUILayoutHelper.DrawInfoMessage("No types to select.");
     }
 }
Esempio n. 4
0
        protected override void DrawChangeableElements()
        {
            base.DrawChangeableElements();

            var myClass        = target as CollectionViewSource;
            var srcGenericMenu = new GenericMenu();

            for (var index = 0; index < _srcNameProp.Count; index++)
            {
                var srcCollection = _srcNameProp[index];
                var index1        = index;
                srcGenericMenu.AddItem(new GUIContent(srcCollection), index == _srcIndex, () =>
                {
                    _srcIndex = index1;
                    UpdateSerializedProperties();
                });
            }

            var isSelectedCollectionValid = _srcIndex >= 0 && _srcNameProp.Count > _srcIndex;

            if (!isSelectedCollectionValid)
            {
                EditorGUILayout.HelpBox("Source Collection Property is no longer valid consider fixing it! If you refactored the name of property you can reserialize it with attribute usage, click here to get needed attribute copied in you clip board.", MessageType.Error);
                var rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                {
                    $"[{nameof(FormerlyBindedAs)}(\"{myClass.SrcCollectionName.PropertyName}\")]".CopyToClipboard();
                }
            }

            EditorGUILayoutHelper.PopGenericMenuAsDropDown(new GUIContent("Source Collection"), new GUIContent(isSelectedCollectionValid ? _srcNameProp[_srcIndex] : (myClass.SrcCollectionName is null ? "Empty" : myClass.SrcCollectionName.PropertyName)), srcGenericMenu, contentColor: isSelectedCollectionValid ? (Color?)null : Color.red);
        }
Esempio n. 5
0
 public static bool Foldout(bool foldout, string content, DrawDelegate draw)
 {
     foldout = EditorGUILayout.Foldout(foldout, content);
     if (foldout)
     {
         EditorGUILayoutHelper.Indent(draw);
     }
     return(foldout);
 }
        private void OnGUI()
        {
            _mainScroll = EditorGUILayout.BeginScrollView(_mainScroll);
            EditorGUILayout.LabelField(new GUIContent("Select things you want to test:"));
            EditorGUILayoutHelper.DrawLine();
            _testScenes = EditorGUILayout.Toggle(new GUIContent("Scenes"), _testScenes);
            EditorGUI.indentLevel++;
            if (!_testScenes)
            {
                GUI.enabled = false;
            }
            _testActiveScene         = EditorGUILayout.Toggle(new GUIContent("Active scene"), _testActiveScene);
            _testActiveBuildScenes   = EditorGUILayout.Toggle(new GUIContent("Active build scenes"), _testActiveBuildScenes);
            _testInactiveBuildScenes = EditorGUILayout.Toggle(new GUIContent("Inactive build scenes"), _testInactiveBuildScenes);
            _testNonBuildScenes      = EditorGUILayout.Toggle(new GUIContent("Non-build scenes"), _testNonBuildScenes);
            EditorGUI.indentLevel--;
            GUI.enabled  = true;
            _testPrefabs = EditorGUILayout.Toggle(new GUIContent("Prefabs"), _testPrefabs);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Select All")))
            {
                SetAllTestValues(true);
            }
            if (GUILayout.Button(new GUIContent("Deselect All")))
            {
                SetAllTestValues(false);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayoutHelper.DrawLine();

            EditorGUILayout.HelpBox("If there is no test case class for a specific binder we can't test it, should test throw error on missing test cases?", MessageType.Warning);
            _testAbortOnMissingTestCase = EditorGUILayout.Toggle(new GUIContent("Throw (Recommended)"), _testAbortOnMissingTestCase);

            EditorGUILayoutHelper.DrawLine();

            if (GUILayout.Button(new GUIContent("Test")))
            {
                try
                {
                    BindingConnectionTest.DoTest(_testAbortOnMissingTestCase, _testScenes, _testActiveScene, _testActiveBuildScenes, _testInactiveBuildScenes, _testNonBuildScenes, _testPrefabs);

                    EditorUtility.DisplayDialog("Success", "Test done without any errors", "Ok", "Cancel");
                }
                catch (Exception e)
                {
                    EditorUtility.DisplayDialog("Error", e.Message, "Ok", "Cancel");
                }
            }


            EditorGUILayout.EndScrollView();
        }
Esempio n. 7
0
            public ScrollbarScope(Scrollbar scrollbar)
            {
                _scrollbar = scrollbar;

                _outerVerticalBlock = EditorGUILayoutHelper.VerticalBlock(out Rect windowRect);

                if (Event.current.type == EventType.Repaint)
                {
                    _scrollbar._windowRect = windowRect;
                }

                _scrollView = EditorGUILayoutHelper.ScrollViewBlock(ref _scrollbar._position, _scrollbar._visible);

                _innerVerticalBlock = EditorGUILayoutHelper.VerticalBlock(out _newWholeListRect);
            }
Esempio n. 8
0
        void onGUIGenRectTransform(RectTransform transform, AutoBindFieldInfo field)
        {
            //如果是RectTransform,那么可以当列表。
            bool isList = field.getValueOrDefault <bool>("isList");

            if (EditorGUILayoutHelper.toggle("列表", isList, out isList))
            {
                field.propDict["isList"] = isList;
            }
            if (isList)
            {
                GameObject template = field.getValueOrDefault <GameObject>("template");
                if (EditorGUILayoutHelper.objectField("列表模板", template, out template, true))
                {
                    field.propDict["template"] = template;
                }
            }
        }
Esempio n. 9
0
        private void DrawContent()
        {
            using (new FixedRect(_preventExpandingHeight, position.width))
            {
                using (EditorGUILayoutHelper.VerticalBlock(_preventExpandingHeight,
                                                           DropdownStyle.BackgroundColor, out float contentHeight))
                {
                    _selectionTree.Draw();

                    if (Event.current.type == EventType.Repaint)
                    {
                        _contentHeight = contentHeight;
                    }
                }

                EditorGUIHelper.DrawBorders(position.width, position.height, DropdownStyle.BorderColor);
            }
        }
Esempio n. 10
0
        protected void DrawErosion(GridGraph graph)
        {
            graph.erodeIterations = EditorGUILayout.IntField(new GUIContent("Erosion iterations", "Sets how many times the graph should be eroded. This adds extra margin to objects."), graph.erodeIterations);
            graph.erodeIterations = graph.erodeIterations < 0 ? 0 : (graph.erodeIterations > 16 ? 16 : graph.erodeIterations);             //Clamp iterations to [0,16]

            if (graph.erodeIterations > 0)
            {
                EditorGUI.indentLevel++;
                graph.erosionUseTags = EditorGUILayout.Toggle(new GUIContent("Erosion Uses Tags", "Instead of making nodes unwalkable, " +
                                                                             "nodes will have their tag set to a value corresponding to their erosion level, " +
                                                                             "which is a quite good measurement of their distance to the closest wall.\nSee online documentation for more info."),
                                                              graph.erosionUseTags);
                if (graph.erosionUseTags)
                {
                    EditorGUI.indentLevel++;
                    graph.erosionFirstTag = EditorGUILayoutHelper.TagField("First Tag", graph.erosionFirstTag, () => AstarPathEditor.EditTags());
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
            }
        }
Esempio n. 11
0
            private void OnGUI()
            {
                _data.CollectScenes = EditorGUILayout.Toggle("Scenes", _data.CollectScenes);
                EditorGUI.indentLevel++;
                var originalGUIEnabled = GUI.enabled;

                if (!_data.CollectScenes)
                {
                    GUI.enabled = false;
                }
                _data.CollectActiveScene       = EditorGUILayout.Toggle("Active Scene", _data.CollectActiveScene);
                _data.CollectActiveBuildScenes =
                    EditorGUILayout.Toggle("Active build scenes", _data.CollectActiveBuildScenes);
                _data.CollectInactiveBuildScenes =
                    EditorGUILayout.Toggle("Inactive build scenes", _data.CollectInactiveBuildScenes);
                _data.CollectNonBuildScenes = EditorGUILayout.Toggle("Non-build Scenes", _data.CollectNonBuildScenes);
                GUI.enabled = originalGUIEnabled;
                EditorGUI.indentLevel--;
                _data.CollectPrefabs = EditorGUILayout.Toggle("Prefabs", _data.CollectPrefabs);
                EditorGUILayoutHelper.DrawLine();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Select All")))
                {
                    _data.SelectAll();
                }
                if (GUILayout.Button(new GUIContent("Deselect All")))
                {
                    _data.DeselectAll();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayoutHelper.DrawLine();

                if (GUILayout.Button(new GUIContent("Done")))
                {
                    _onCloseEvent?.Invoke(_data);
                    this.Close();
                }
            }
        private void DrawMainDisplay()
        {
            if (!Application.isPlaying)
            {
                EditorGUILayoutHelper.CenteredMessage("Simulation In-Active");
                return;
            }

            switch (mode)
            {
            case Mode.Stats:
                DrawStatsWindow();
                break;

            case Mode.Environment:
                DrawEnvironmentWindow();
                break;

            case Mode.Settings:
                DrawSettingsWindow();
                break;
            }
        }
Esempio n. 13
0
        void DrawWithEditor(SerializedProperty property)
        {
            Editor editor = Editor.CreateEditor(property.objectReferenceValue);

            if (editor == null)
            {
                return;
            }

            Rect foldoutRect = GUILayoutUtility.GetLastRect();

            foldoutRect.width   = 20.0f;
            property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "");

            if (property.isExpanded)
            {
                if (property.isArray)
                {
                    property.arraySize = EditorGUILayout.IntField("Size", property.arraySize);
                }

                try
                {
                    EditorGUILayoutHelper.Indent(() =>
                    {
                        editor.OnInspectorGUI();
                    });
                }
                catch (Exception exc)
                {
                    Dbg.LogExc(exc);
                    Dbg.LogErrorRelease("Exception thrown with InlineObjectAttriute.useEditor = true. Does the serialized object type have an Editor?");
                    throw exc;
                }
            }
        }