private void OnGUI()
        {
            if (null == Backend)
            {
                EditorGUILayout.LabelField($"Backend not supported for backend type '{m_BackendType.ToString()}'");
                return;
            }

            try
            {
                Backend.Targets = m_Targets;
                Backend.Mode    = m_Mode;

                Backend.OnGUI();

                m_Targets = Backend.Targets;
            }
            catch (ExitGUIException)
            {
                throw;
            }
            catch (Exception e)
            {
                TinyEditorAnalytics.SendExceptionOnce("Inspector.OnGUI", e);
                throw;
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            try
            {
                if (s_GuiContents == null)
                {
                    s_GuiContents = new GUIContents(UTinyEditorApplication.ContextType);
                }

                GUI.enabled = !EditorApplication.isPlayingOrWillChangePlaymode;

                DoLayout();
                GUI.enabled = true;
            }
            catch (ExitGUIException)
            {
                throw;
            }
            catch (Exception e)
            {
                TinyEditorAnalytics.SendExceptionOnce("Editor.OnGUI", e);
                throw;
            }
        }
Ejemplo n.º 3
0
        private void OnGUI()
        {
            if (null == EditorContext)
            {
                EditorGUILayout.LabelField("No project loaded.");
                return;
            }

            try
            {
                VerifyEntityGroups();

                using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true)))
                {
                    if (GUILayout.Button("Create", EditorStyles.toolbarDropDown, GUILayout.Width(75)))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Create EntityGroup"), false, () =>
                        {
                            EntityGroupManager.CreateNewEntityGroup();
                        });

                        menu.AddSeparator("");

                        if (LoadedEntityGroups.Count > 0)
                        {
                            // Entity
                            menu.AddItem(new GUIContent("Create Entity"), false, () =>
                            {
                                m_TreeView.CreateEntity(ActiveScene);
                                InvalidateSceneGraph();
                            });
                            menu.AddItem(new GUIContent("Create Static Entity"), false, () =>
                            {
                                m_TreeView.CreateStaticEntity(ActiveScene);
                                InvalidateSceneGraph();
                            });
                        }

                        menu.ShowAsContext();
                    }

                    if (GUILayout.Button("Load", EditorStyles.toolbarDropDown, GUILayout.Width(75)))
                    {
                        EntityGroupManager.ShowOpenEntityGroupMenu();
                    }

                    // HACK For some reason flexible space does not work here...
                    GUILayout.Space(position.width - 50);
                }

                var searchRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
                m_TreeView.FilterString = m_Filter.OnGUI(searchRect, m_TreeView.FilterString);

                if (LoadedEntityGroupCount == 0)
                {
                    EditorGUILayout.LabelField("No EntityGroups are loaded.");
                    return;
                }

                m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
                {
                    var rect = EditorGUILayout.GetControlRect(false, position.height - 42.0f);
                    rect.width = Screen.width + 1;
                    rect.x     = 0;
                    m_TreeView.OnGUI(rect);

                    // Check for a click on empty space.
                    rect.height = rect.height - m_TreeView.totalHeight;
                    rect.y     += m_TreeView.totalHeight;
                    if (rect.height > 0 && Event.current.type == EventType.MouseDown &&
                        rect.Contains(Event.current.mousePosition))
                    {
                        Selection.instanceIDs = new int[0];
                    }
                }
                EditorGUILayout.EndScrollView();

                ExecuteCommands();
            }
            catch (ExitGUIException)
            {
                throw;
            }
            catch (Exception e)
            {
                TinyEditorAnalytics.SendExceptionOnce("Hierarchy.OnGUI", e);
                throw;
            }
        }