示例#1
0
        private void ShowGraphEditor()
        {
            // TODO: Ensure only one window instance per-graph is open

            GraphEditorWindow window = CreateInstance <GraphEditorWindow>();
            ExecGraph         graph  = target as ExecGraph;

            // Create a toolbar to run/compile
            var toolbar = new IMGUIContainer(() =>
            {
                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                if (GUILayout.Button("Execute", EditorStyles.toolbarButton))
                {
                    graph.Execute();
                }

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

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            });

            window.rootVisualElement.Add(toolbar);

            window.Show();
            window.Load(graph);
        }
示例#2
0
        VisualElement CreateMeshVisual(int i, Mesh asset, int height)
        {
            if (!m_editors.TryGetValue(asset, out Editor e))
            {
                e = Editor.CreateEditor(asset);
                m_editors.Add(asset, e);
            }

            var horizontal = new VisualElement();

            horizontal.AddToClassList("horizontal");

            {
                var imguiContainer = new IMGUIContainer(() =>
                {
                    e.OnInteractivePreviewGUI(GUILayoutUtility.GetRect(height, height), null);
                });
                horizontal.Add(imguiContainer);
            }
            {
                var left = new VisualElement();
                left.AddToClassList("grow");
                left.Add(new Label($"[{i:00}]{asset.name}"));
                left.Add(new Label($"{asset.vertexCount}vertices"));
                left.Add(new Label($"{asset.triangles.Length / 3}triangles"));
                left.Add(new Label($"{asset.subMeshCount}subMeshes"));
                horizontal.Add(left);
            }
            return(horizontal);
        }
示例#3
0
 public override void OnEnable()
 {
     base.OnEnable();
     m_ImguiContainer = new IMGUIContainer(OnIMGUI);
     m_TableContentsPanel.Add(m_ImguiContainer);
     m_ImguiContainer.StretchToParentSize();
 }
示例#4
0
        public override VisualElement CreateInspectorGUI()
        {
            var root = new VisualElement();

            IMGUIContainer defaultInspector = new IMGUIContainer(() => DrawDefaultInspector());

            root.Add(defaultInspector);

            E atomEvent = target as E;

            var runtimeWrapper = new VisualElement();

            runtimeWrapper.SetEnabled(Application.isPlaying);
            runtimeWrapper.Add(new Button(() =>
            {
                atomEvent.Raise(atomEvent.InspectorRaiseValue);
            })
            {
                text = "Raise"
            });
            root.Add(runtimeWrapper);

            StackTraceEditor.RenderStackTrace(root, atomEvent.GetInstanceID());

            return(root);
        }
示例#5
0
        void Init()
        {
            var    editors      = PopulateCache();
            Object editorTarget = editor.targets[0];
            string editorTitle  = ObjectNames.GetInspectorTitle(editorTarget);

            var inspectorElementMode = InspectorElement.GetModeFromInspectorMode(inspectorWindow.inspectorMode);

            if (inspectorWindow.useUIElementsDefaultInspector)
            {
                inspectorElementMode &= ~(InspectorElement.Mode.IMGUIDefault);
            }

            m_InspectorElement = new InspectorElement(editor, inspectorElementMode)
            {
                focusable = false
            };


            m_Header = BuildHeaderElement(editorTitle);
            m_Footer = BuildFooterElement(editorTitle);

            m_InspectorElement.name = editorTitle + "Inspector";
            m_InspectorElement.style.paddingBottom = InspectorWindow.kEditorElementPaddingBottom;

            if (EditorNeedsVerticalOffset(editors, editorTarget))
            {
                m_InspectorElement.style.overflow = Overflow.Hidden;
            }

            UpdateInspectorVisibility();
        }
        public TracingTimeline(VseGraphView vseGraphView, State vsWindowState, IMGUIContainer imguiContainer)
        {
            m_VseGraphView   = vseGraphView;
            m_VSWindowState  = vsWindowState;
            m_ImguiContainer = imguiContainer;
            m_TimeArea       = new TimeArea();
            m_Overlay        = new AnimEditorOverlay()
            {
                PlayHeadColor = new Color(0.2117647F, 0.6039216F, 0.8F)
            };
            m_State         = new TimelineState(m_TimeArea);
            m_Overlay.state = m_State;

            var         debugger = m_VSWindowState?.CurrentGraphModel?.Stencil?.Debugger;
            IGraphTrace trace    = debugger?.GetGraphTrace(m_VSWindowState?.CurrentGraphModel,
                                                           m_VSWindowState.CurrentTracingTarget);

            if (trace?.AllFrames != null && trace.AllFrames.Count > 0)
            {
                int firstFrame = trace.AllFrames[0].Frame;
                int lastFrame  = trace.AllFrames[trace.AllFrames.Count - 1].Frame;
                m_TimeArea.SetShownRange(
                    firstFrame - k_MinTimeVisibleOnTheRight,
                    lastFrame + k_MinTimeVisibleOnTheRight);
            }
        }
        void BuildEnumKeywordField(PropertySheet propertySheet, ShaderKeyword keyword)
        {
            // Clamp value between entry list
            int value = Mathf.Clamp(keyword.value, 0, keyword.entries.Count - 1);

            // Default field
            var field = new PopupField <string>(keyword.entries.Select(x => x.displayName).ToList(), value);

            field.RegisterValueChangedCallback(evt =>
            {
                this._preChangeValueCallback("Change Keyword Value");
                keyword.value = field.index;
                this._postChangeValueCallback(false, ModificationScope.Graph);
            });

            AddPropertyRowToSheet(propertySheet, field, "Default");

            // Entries
            var container = new IMGUIContainer(() => OnKeywordGUIHandler())
            {
                name = "ListContainer"
            };

            AddPropertyRowToSheet(propertySheet, container, "Entries");
            container.SetEnabled(!keyword.isBuiltIn);
        }
        public MemoryMapPane(UIState s, IViewPaneEventListener l, VisualElement toolbarExtension)
            : base(s, l)
        {
            CurrentTableView = (TableDisplayMode)UnityEditor.EditorPrefs.GetInt("Unity.MemoryProfilerForExtension.Editor.UI.MemoryMapPane.TableDisplayMode", (int)TableDisplayMode.Regions);

            m_ToolbarExtension     = toolbarExtension;
            m_ToolbarExtensionPane = new IMGUIContainer(new Action(OnGUIToolbarExtension));

            s.CurrentMode.ViewPaneChanged += OnViewPaneChanged;
            s.ModeChanged += OnModeChanged;

            string[] displayElements = Enum.GetNames(typeof(MemoryMap.MemoryMap.DisplayElements));
            m_DisplayElementsList = new GUIContent[displayElements.Length];
            for (int i = 0; i < displayElements.Length; ++i)
            {
                m_DisplayElementsList[i] = new GUIContent(displayElements[i]);
            }

            ulong maxSize = 256 * 1024 * 1024; //256 128  64,32,16,8,  4,2,1,512,  256,128,64,32

            m_BytesInRowList = new RowSize[14];
            for (int i = 0; i < m_BytesInRowList.Length; ++i)
            {
                m_BytesInRowList[i] = new RowSize(maxSize >> i);
            }

            m_MemoryMap = new MemoryMap.MemoryMap();
            m_MemoryMap.Setup(m_UIState.snapshotMode.snapshot);
            m_MemoryMap.RegionSelected += OnSelectRegions;
        }
示例#9
0
        internal static EditorElement CreateEditorElement(VisualElement element, IMGUIContainer header, IMGUIContainer footer, SmartInspector smartInspector)
        {
            var editor      = EditorElementRef.GetEditor(element);
            var editorIndex = EditorElementRef.GetEditorIndex(element);
            var inspector   = EditorElementRef.GetInspectorElement(element);

            var window  = smartInspector.propertyEditor;
            var tracker = smartInspector.tracker;


            var data = new EditorElement(element)
            {
                header    = header,
                inspector = inspector,
                footer    = footer,

                index         = editorIndex,
                expandedState = -1,

                editor  = editor,
                window  = window,
                tracker = tracker,

                smartInspector = smartInspector,
            };

            return(data);
        }
示例#10
0
        public ItemBaseInfoBlock(SerializedObject serializedObject, string IDPrefix)
        {
            contentContainer.style.paddingRight = 0;
            this.serializedObject = serializedObject;
            this.IDPrefix         = IDPrefix;
            ID          = serializedObject.FindAutoProperty("ID");
            Name        = serializedObject.FindAutoProperty("Name");
            Icon        = serializedObject.FindAutoProperty("Icon");
            Description = serializedObject.FindAutoProperty("Description");
            type        = serializedObject.FindProperty("type");
            quality     = serializedObject.FindProperty("quality");
            Weight      = serializedObject.FindAutoProperty("Weight");
            StackLimit  = serializedObject.FindAutoProperty("StackLimit");
            Discardable = serializedObject.FindAutoProperty("Discardable");
            text        = "基本信息";
            RefreshCache();
            helpBox             = new HelpBox();
            helpBox.text        = "无错误";
            helpBox.messageType = HelpBoxMessageType.Info;
            Add(helpBox);
            IMGUIContainer inspector = new IMGUIContainer(() =>
            {
                if (serializedObject.targetObject)
                {
                    OnInspectorGUI(serializedObject);
                }
            });

            Add(inspector);
            CheckError();
        }
        public void OnEnable()
        {
            // Creation and assembly of the window.
            var root = rootVisualElement;

            // Construct its contents.
            m_textfieldMenuName = new TextField {
                label = "Submenu Name: ",
                value = "Python Scripts/New Python Script"
            };
            root.Add(m_textfieldMenuName);
            m_helpboxContainer = (new IMGUIContainer(OnValidation));
            root.Add(m_helpboxContainer);
            m_buttonCommitMenuName = new Button {
                text = "Create"
            };
            root.Add(m_buttonCommitMenuName);

            // Assign style sheet.
            root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>("Packages/com.unity.scripting.python/Styles/pythonpopup_uss.uss"));

            // Implement event handles.
            m_textfieldMenuName.RegisterCallback <ChangeEvent <string> >(OnPathEdit);
            m_buttonCommitMenuName.RegisterCallback <MouseUpEvent>(OnCommit);
        }
        public new void OnEnable()
        {
            base.OnEnable();
            titleContent = new GUIContent("Allocator Debugger");

            var root = rootVisualElement;

            root.AddStyleSheetPath("UIPackageResources/StyleSheets/UIElementsDebugger/UIRAllocatorDebugger.uss");
            m_IMGUIToolbar = new IMGUIContainer(OnGUIToolbar);
            m_ScrollView   = new ScrollView()
            {
                style = { flexGrow = 1 }
            };
            m_StatsContainer = new VisualElement();

            m_GlobalStats = new AllocatorStatsDisplay();
            m_PagesStats  = new PagesStatsDisplay();

            var globalStatsLabel = new Label("Global Stats");

            globalStatsLabel.AddToClassList("section-header");
            m_StatsContainer.Add(globalStatsLabel);
            m_StatsContainer.Add(m_GlobalStats);

            var pageStatsLabel = new Label("Pages Stats");

            pageStatsLabel.AddToClassList("section-header");
            m_StatsContainer.Add(pageStatsLabel);
            m_StatsContainer.Add(m_PagesStats);

            m_ScrollView.Add(m_StatsContainer);

            root.Add(m_IMGUIToolbar);
            root.Add(m_ScrollView);
        }
        public override void OnCreate(IWindowModel model)
        {
            base.OnCreate(model);

            m_PlayModeDarkenColor = UIElementsUtility.editorPlayModeTintColor = EditorApplication.isPlayingOrWillChangePlaymode ? editorWindowModel.playModeTintColor : Color.white;

            EditorApplication.playModeStateChanged  += PlayModeStateChangedCallback;
            AnimationMode.onAnimationRecordingStart += RefreshStylesAfterExternalEvent;
            AnimationMode.onAnimationRecordingStop  += RefreshStylesAfterExternalEvent;

            m_NotificationContainer = new IMGUIContainer();
            m_NotificationContainer.StretchToParentSize();
            m_NotificationContainer.pickingMode = PickingMode.Ignore;

            editorWindowModel.notificationVisibilityChanged = NotificationVisibilityChanged;
            editorWindowModel.blurred = Blured;
            editorWindowModel.focused = Focused;
            editorWindowModel.playModeTintColorChanged = PlayModeTintColorChanged;

            if (editorWindowModel.window != null)
            {
                OnRegisterWindow();
                ViewMarginsChanged();
            }

            editorWindowModel.onRegisterWindow         = OnRegisterWindow;
            editorWindowModel.onUnegisterWindow        = OnUnegisterWindow;
            editorWindowModel.onDisplayWindowMenu      = AddUIElementsDebuggerToMenu;
            editorWindowModel.viewMarginsChanged       = ViewMarginsChanged;
            editorWindowModel.rootVisualElementCreated = RootVisualElementCreated;
        }
示例#14
0
        public override void OnCreate(IWindowModel model)
        {
            try
            {
                base.OnCreate(model);

                m_PlayModeDarkenColor = UIElementsUtility.editorPlayModeTintColor =
                    EditorApplication.isPlayingOrWillChangePlaymode ? editorWindowModel.playModeTintColor : Color.white;

                EditorApplication.playModeStateChanged  += PlayModeStateChangedCallback;
                AnimationMode.onAnimationRecordingStart += RefreshStylesAfterExternalEvent;
                AnimationMode.onAnimationRecordingStop  += RefreshStylesAfterExternalEvent;

                m_NotificationContainer = new IMGUIContainer();
                m_NotificationContainer.StretchToParentSize();
                m_NotificationContainer.pickingMode = PickingMode.Ignore;

                RegisterImguiContainerGUICallbacks();

                // Window is non-null when set by deserialization; it's usually null when OnCreate is called.
                if (editorWindowModel.window != null)
                {
                    RegisterWindow();
                }
            }
            catch (Exception e)
            {
                // Log error to easily diagnose issues with panel initialization and then rethrow it.
                Debug.LogException(e);
                throw;
            }
        }
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            if (panel != null)
            {
                IMGUIContainer imguiContainer = panel.focusController.GetLeafFocusedElement() as IMGUIContainer;

                if (imguiContainer != null)
                {
                    if (!evt.Skip(imguiContainer) && imguiContainer.SendEventToIMGUI(evt))
                    {
                        evt.StopPropagation();
                        evt.PreventDefault();
                    }

                    if (!evt.isPropagationStopped && evt.propagateToIMGUI)
                    {
                        evt.skipElements.Add(imguiContainer);
                        EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt);
                    }
                }
                else if (panel.focusController.GetLeafFocusedElement() != null)
                {
                    evt.target = panel.focusController.GetLeafFocusedElement();
                    EventDispatchUtilities.PropagateEvent(evt);
                }
                else
                {
                    EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt);
                }
            }

            evt.propagateToIMGUI = false;
            evt.stopDispatch     = true;
        }
示例#16
0
 public void InspectTree(BehaviourTree tree)
 {
     Clear();
     if (serializedObject != null)
     {
         serializedObject.Dispose();
     }
     this.tree = tree;
     if (tree)
     {
         serializedObject = new SerializedObject(tree);
         IMGUIContainer container = new IMGUIContainer(() =>
         {
             if (tree)
             {
                 serializedObject.UpdateIfRequiredOrScript();
                 EditorGUI.BeginChangeCheck();
                 EditorGUILayout.PropertyField(serializedObject.FindProperty("_name"), new GUIContent("行为树名称"));
                 EditorGUILayout.PropertyField(serializedObject.FindProperty("description"), new GUIContent("行为树描述"));
                 if (EditorGUI.EndChangeCheck())
                 {
                     serializedObject.ApplyModifiedProperties();
                 }
             }
         });
         Add(container);
     }
 }
        public MemoryMapDiffPane(UIState s, IViewPaneEventListener l, VisualElement toolbarExtension)
            : base(s, l)
        {
            CurrentTableView = (TableDisplayMode)UnityEditor.EditorPrefs.GetInt("Unity.MemoryProfiler.Editor.UI.MemoryMapPaneDiff.TableDisplayMode", (int)TableDisplayMode.Regions);

            m_ToolbarExtension = toolbarExtension;
            m_ToolbarExtensionPane = new IMGUIContainer(new Action(OnGUIToolbarExtension));

            s.CurrentMode.ViewPaneChanged += OnViewPaneChanged;
            s.ModeChanged += OnModeChanged;

            string[] displayElements = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.DisplayElements));
            m_DisplayElementsList = new GUIContent[displayElements.Length];
            for (int i = 0; i < displayElements.Length; ++i)
                m_DisplayElementsList[i] = new GUIContent(displayElements[i]);

            string[] colorSchemes = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.ColorScheme));
            m_ColorSchemeList = new GUIContent[colorSchemes.Length];
            for (int i = 0; i < colorSchemes.Length; ++i)
                m_ColorSchemeList[i] = new GUIContent(colorSchemes[i]);

            ulong maxSize = 256 * 1024 * 1024; // 256,128,  64,32,16,8,  4,2,1,512,  256,128,64,32
            m_BytesInRowList = new RowSize[14];
            for (int i = 0; i < m_BytesInRowList.Length; ++i)
                m_BytesInRowList[i] = new RowSize(maxSize >> i);

            UIState.SnapshotMode mode1 = m_UIState.FirstMode as UIState.SnapshotMode;
            UIState.SnapshotMode mode2 = m_UIState.SecondMode as UIState.SnapshotMode;
            m_ActiveMode = mode1;

            m_MemoryMap = new MemoryMap.MemoryMapDiff();
            m_MemoryMap.Setup(mode1.snapshot, mode2.snapshot);
            m_MemoryMap.RegionSelected += OnSelectRegions;
        }
示例#18
0
        public virtual void OnCreate(IWindowModel model)
        {
            m_Model = model;
            m_Panel = EditorPanel.FindOrCreate(model as ScriptableObject);

            m_Panel.visualTree.SetSize(m_Model.size);
            m_Panel.IMGUIEventInterests = m_Model.eventInterests;

            imguiContainer = new IMGUIContainer(m_Model.onGUIHandler)
            {
                useOwnerObjectGUIState = true
            };
            imguiContainer.StretchToParentSize();
            imguiContainer.viewDataKey = "Dockarea";
            imguiContainer.name        = VisualElementUtils.GetUniqueName("Dockarea");
            imguiContainer.tabIndex    = -1;
            imguiContainer.focusOnlyIfHasFocusableControls = false;

            m_Panel.visualTree.Insert(0, imguiContainer);
            Assert.IsNull(m_Panel.rootIMGUIContainer);
            m_Panel.rootIMGUIContainer = imguiContainer;

            m_Model.sizeChanged           = OnSizeChanged;
            m_Model.eventInterestsChanged = OnEventsInterestsChanged;
        }
            public HeapStats(HeapStatistics stats)
            {
                m_Stats = stats;

                m_IMGUIStats = new IMGUIContainer(OnGUIStats);
                Add(m_IMGUIStats);
            }
        public override VisualElement CreateInspectorGUI()
        {
            if (m_Root == null)
            {
                m_Root = Resources.GetTemplate("StringTableEditor");
                m_Root.Bind(serializedObject);

                m_Root.Q <PropertyField>("m_TableName").Q <TextField>().RegisterCallback <ChangeEvent <string> >(TableNameChanged);
                m_Root.Q <PropertyField>("m_TableName").Q <TextField>().isDelayed = true; // Prevent an undo for every char changed.
                var tableContainer = m_Root.Q("tableContainer");
                m_ImguiContainer = new IMGUIContainer(OnIMGUI);

                // Workaround for IMGUI resize bug https://unity.slack.com/archives/C3414V4UV/p1533657274000148
                m_ImguiContainer.style.overflow = Overflow.Visible;

                tableContainer.Add(m_ImguiContainer);
                m_ImguiContainer.StretchToParentSize();
                m_DetailedPanel          = m_Root.Q("detailedPanel");
                m_DetailedPanelContainer = m_Root.Q("detailedPanelContainer");

                m_PluralModeToggle = m_DetailedPanelContainer.Q <Toggle>("pluralModeToggle");
                m_PluralModeToggle.RegisterCallback <ChangeEvent <bool> >(evt => RefreshEditPanel());
            }
            return(m_Root);
        }
        public VisualElement DrawNode(INode node, Action <object> onValueChanged)
        {
            VisualElement element       = null;
            var           useOdinDrawer = false;

#if ODIN_INSPECTOR
            useOdinDrawer = true;
#endif
            if (useOdinDrawer)
            {
                element = new IMGUIContainer(() => node.DrawOdinPropertyInspector());
                return(element);
            }

            element = new VisualElement();
            var data   = GetData(node);
            var fields = fiedlsContainer.GetFields(data);

            foreach (var field in fields)
            {
                var view = DrawField(field);
                view.style.marginBottom = 4;
                element.Add(view);
            }

            //save source object
            data.Property.serializedObject.
            ApplyModifiedPropertiesWithoutUndo();

            return(element);
        }
        private void SetupVisualElements()
        {
            m_ToolbarIMGUIElement = new IMGUIContainer(DoToolbarGUI)
            {
                name = "spriteEditorWindowToolbar",
            };
            m_MainViewIMGUIElement = new IMGUIContainer(DoTextureAndModulesGUI)
            {
                name = "mainViewIMGUIElement"
            };
            m_MainViewElement = new VisualElement()
            {
                name = "spriteEditorWindowMainView",
            };
            m_ModuleViewElement = new VisualElement()
            {
                name        = "moduleViewElement",
                pickingMode = PickingMode.Ignore
            };
            m_MainViewElement.Add(m_MainViewIMGUIElement);
            m_MainViewElement.Add(m_ModuleViewElement);
            var root = this.GetRootVisualContainer();

            root.AddStyleSheetPath("StyleSheets/SpriteEditor/SpriteEditor.uss");
            root.Add(m_ToolbarIMGUIElement);
            root.Add(m_MainViewElement);
        }
示例#23
0
        private bool SetupVisualElements()
        {
            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(SpriteEditorWindowStyles.styleSheetPath);

            if (styleSheet != null)
            {
                m_ToolbarIMGUIElement = new IMGUIContainer(DoToolbarGUI)
                {
                    name = "spriteEditorWindowToolbar",
                };
                m_MainViewIMGUIElement = new IMGUIContainer(DoTextureAndModulesGUI)
                {
                    name = "mainViewIMGUIElement"
                };
                m_MainViewElement = new VisualElement()
                {
                    name = "spriteEditorWindowMainView",
                };
                m_ModuleViewElement = new VisualElement()
                {
                    name        = "moduleViewElement",
                    pickingMode = PickingMode.Ignore
                };
                m_MainViewElement.Add(m_MainViewIMGUIElement);
                m_MainViewElement.Add(m_ModuleViewElement);
                var root = rootVisualElement;
                root.styleSheetList.Add(styleSheet);
                root.Add(m_ToolbarIMGUIElement);
                root.Add(m_MainViewElement);
                return(true);
            }
            return(false);
        }
示例#24
0
        private static void OnUpdate()
        {
            if (MustGetToolbar())
            {
                //Find the first toolBar
                UnityEngine.Object[] toolbars = Resources.FindObjectsOfTypeAll(_toolbarType);
                _currentToolbar = toolbars.Length > 0 ? (ScriptableObject)toolbars[0] : null;

                if (_currentToolbar != null)
                {
                    // Get it's visual tree
#if UNITY_2020_1_OR_NEWER
                    var           windowBackend = _windowBackend.GetValue(_currentToolbar);
                    VisualElement visualTree    = (VisualElement)_viewVisualTree.GetValue(windowBackend, null);
#else
                    VisualElement visualTree = (VisualElement)_viewVisualTree.GetValue(_currentToolbar, null);
#endif

                    // Get first child which 'happens' to be toolbar IMGUIContainer
                    IMGUIContainer container = (IMGUIContainer)visualTree[0];


                    // (Re)attach handler
                    Action handler = (Action)_imguiContainerOnGui.GetValue(container);
                    handler -= OnGUI;
                    handler += OnGUI;
                    _imguiContainerOnGui.SetValue(container, handler);
                }
            }
        }
示例#25
0
        IMGUIContainer BuildFooterElement(string editorTitle)
        {
            IMGUIContainer footerElement = inspectorWindow.CreateIMGUIContainer(FooterOnGUI, editorTitle + "Footer");

            footerElement.style.height = kFooterDefaultHeight;
            return(footerElement);
        }
        public override VisualElement CreateInspectorGUI()
        {
            var root = new VisualElement();

            IMGUIContainer defaultInspector = new IMGUIContainer(() => DrawDefaultInspector());

            root.Add(defaultInspector);

            var eventInstancer = target as AtomEventInstancer <T, E>;
            E   atomEvent      = eventInstancer.Event;

            var runtimeWrapper = new VisualElement();

            runtimeWrapper.SetEnabled(Application.isPlaying);
            runtimeWrapper.Add(new Button(() =>
            {
                atomEvent.Raise(eventInstancer.InspectorRaiseValue);
            })
            {
                text = "Raise"
            });
            root.Add(runtimeWrapper);

            return(root);
        }
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var container = new VisualElement();
            var helpBox   = new IMGUIContainer(() => EditorGUILayout.HelpBox($"{nameof(GimmickTarget)} を {nameof(GimmickTarget.Item)} にするには {nameof(Item)} を指定する必要があります。", MessageType.Warning));
            var itemField = new ObjectField(property.displayName)
            {
                objectType = typeof(Item.Implements.Item),
                value      = property.objectReferenceValue
            };

            itemField.Bind(property.serializedObject);

            itemField.RegisterCallback <ChangeEvent <UnityEngine.Object> >(e =>
            {
                property.objectReferenceValue = e.newValue;
                SwitchDisplayHelp(e.newValue == null);
                property.serializedObject.ApplyModifiedProperties();
            });

            void SwitchDisplayHelp(bool show)
            {
                helpBox.SetVisibility(show);
            }

            SwitchDisplayHelp(property.objectReferenceValue == null);

            container.Add(helpBox);
            container.Add(itemField);

            return(container);
        }
        internal ReorderableListView(
            List <T> dataList,
            string header     = "Reorder data:",
            bool allowReorder = true,
            Func <T, string> getDisplayText = null)
        {
            m_DataList     = dataList;
            m_HeaderLabel  = header;
            m_AllowReorder = allowReorder;

            // setup GetDisplayTextFunc
            if (getDisplayText == null)
            {
                m_GetDisplayTextFunc = data => data.ToString();
            }
            else
            {
                m_GetDisplayTextFunc = getDisplayText;
            }

            RebuildTextList();

            // should we set up a new style sheet?  allow user overrides?
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/ReorderableSlotListView"));

            m_Container = new IMGUIContainer(() => OnGUIHandler())
            {
                name = "ListContainer"
            };
            Add(m_Container);
        }
示例#29
0
        protected override IMGUIContainer EnsureNamingConventions(ChangeEvent <string> evt = null)
        {
            IMGUIContainer container = base.EnsureNamingConventions(evt);

            if (container != null)
            {
                container.style.alignItems    = Align.FlexEnd;
                container.style.paddingBottom = 20;
                container.name += "_NamingConvention";
                if (InspectorEnabled)
                {
                    objectNameSetter      = new Button(SetObjectName);
                    objectNameSetter.name = "objectNameSetter";
                    objectNameSetter.text = "Fix Naming Convention";
                    container.Add(objectNameSetter);
                    RootVisualElement.Add(container);
                    container.SendToBack();
                }
                else
                {
                    RootVisualElement.Add(container);
                    container.SendToBack();
                }
            }
            else if (objectNameSetter != null)
            {
                objectNameSetter.TryRemoveFromParent();
            }

            return(null);
        }
示例#30
0
    // エディタ拡張の場合、OnInspectorGUIではなくCreateInspectorGUIを使う
    public override VisualElement CreateInspectorGUI()
    {
        var root = new VisualElement();

        // デフォルトのInspector表示を追加
        IMGUIContainer defaultInspector = new IMGUIContainer(() => DrawDefaultInspector());

        root.Add(defaultInspector);

        // IMGUIContainerを使ってIMGUIでUIを描画
        root.Add(new IMGUIContainer(() => {
            GUILayout.Space(16);
            GUILayout.BeginVertical("Box");
            GUILayout.Label("ここはIMGUIの拡張です");
            if (GUILayout.Button("Buttom From IMGUI"))
            {
                Debug.Log("Click IMGUI Button.");
            }

            GUILayout.EndVertical();
        }));

        // カスタム用のVisualElementを追加

        var uxmlPath = "Assets/_UIElementsCustomEditor/Editor/" + typeof(UIElementCustomEditor).Name + ".uxml";
        var uxml     = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(uxmlPath);

        root.Add(uxml.CloneTree());

        // VisualElementのボタンイベントを追加
        var target = serializedObject.targetObject as UIElementCustomEditorTestObject;

        if (target == null)
        {
            return(root);
        }

        var childButton1 = root.Q <Button>("ChildButton1");

        if (childButton1 != null)
        {
            childButton1.clickable.clicked += target.Connect1;
        }

        var childButton2 = root.Q <Button>("ChildButton2");

        if (childButton2 != null)
        {
            childButton2.clickable.clicked += target.Connect2;
        }

        var parentButton = root.Q <Button>("ParentButton");

        if (parentButton != null)
        {
            parentButton.clickable.clicked += target.Connect3;
        }

        return(root);
    }