Пример #1
0
        private void DrawItem(UnityEngine.Rect rect, EntityItem item, RowGUIArgs args)
        {
            using (new GuiColorScope(item.Node.EnabledInHierarchy ? UnityEngine.Color.white : HierarchyColors.Hierarchy.Disabled))
            {
                if (!args.selected && rect.Contains(Event.current.mousePosition))
                {
                    HierarchyGui.BackgroundColor(rect, HierarchyColors.Hierarchy.Hover);
                    if (Event.current.type == EventType.Layout)
                    {
                        m_CurrentHoveredRect = rect;
                    }
                }

                CenterRectUsingSingleLineHeight(ref args.rowRect);
                base.RowGUI(args);
            }
        }
Пример #2
0
        private void UpdateConfigView()
        {
            if (Project == null)
            {
                return;
            }

            var configEntity = Project.WorldManager.GetConfigEntity();

            if (configEntity == Entity.Null)
            {
                return;
            }

            var configEntityRef = m_ComponentCache.GetEntityReference(configEntity);
            var rect            = EditorGUILayout.GetControlRect(false, k_FooterHeight);

            // Background
            if (Selection.activeInstanceID == configEntityRef.GetInstanceID())
            {
                HierarchyGui.BackgroundColor(rect, HierarchyColors.Hierarchy.Selection);
            }
            else if (rect.Contains(Event.current.mousePosition))
            {
                HierarchyGui.BackgroundColor(rect, HierarchyColors.Hierarchy.Hover);
            }

            // Draw top line
            var topLine = rect;

            topLine.width += 1;
            topLine.height = 1;
            HierarchyGui.BackgroundColor(topLine, HierarchyColors.Hierarchy.SceneSeparator);

            // Draw configuration entity
            var entityRect = rect;

            entityRect.x += 2;
            entityRect.y += 2;

            // Draw entity icon
            var iconRect = entityRect;

            iconRect.y    += 1;
            iconRect.width = 18;
            EditorGUI.LabelField(iconRect, new GUIContent {
                image = Icons.Entity
            });

            // Draw entity label
            var labelRect = entityRect;

            labelRect.x += 18;
            labelRect.y += 2;
            EditorGUI.LabelField(labelRect, "Configuration", GUI.skin.label);

            if (GUI.Button(rect, new GUIContent(), GUI.skin.label))
            {
                Selection.activeInstanceID = configEntityRef.GetInstanceID();
            }
        }
Пример #3
0
        private void DrawItem(UnityEngine.Rect rect, SceneItem item, RowGUIArgs args)
        {
            if (null == item)
            {
                return;
            }

            // Draw scene separators and background
            var indent = GetContentIndent(item);

            if (!args.selected)
            {
                var headerRect = rect;
                headerRect.width += 1;

                var topLine = headerRect;
                topLine.height = 1;
                HierarchyGui.BackgroundColor(topLine, HierarchyColors.Hierarchy.SceneSeparator);

                headerRect.y      += 2;
                headerRect.height -= 2;
                HierarchyGui.BackgroundColor(headerRect, HierarchyColors.Hierarchy.SceneItem);
                if (rect.Contains(Event.current.mousePosition))
                {
                    HierarchyGui.BackgroundColor(headerRect, HierarchyColors.Hierarchy.Hover);
                    if (Event.current.type == EventType.Layout)
                    {
                        m_CurrentHoveredRect = rect;
                    }
                }

                var bottomLine = headerRect;
                bottomLine.y     += bottomLine.height - 2;
                bottomLine.height = 1;
                HierarchyGui.BackgroundColor(bottomLine, HierarchyColors.Hierarchy.SceneSeparator);
            }

            // Draw scene icon
            rect.y     += 2;
            rect.x      = indent;
            rect.width -= indent;

            var iconRect = rect;

            iconRect.width = 20;

            var image = ActiveScene == item.Scene ? Icons.ActiveScene : Icons.Scene;

            EditorGUI.LabelField(iconRect, new UnityEngine.GUIContent {
                image = image
            });

            // Draw scene label
            rect.x     += 20;
            rect.width -= 40;

            var style   = ActiveScene == item.Scene ? EditorStyles.boldLabel : UnityEngine.GUI.skin.label;
            var label   = item.displayName;
            var project = Application.AuthoringProject;

            if (!project.GetScenes().Contains(new SceneReference {
                SceneGuid = item.Scene.SceneGuid.Guid
            }))
            {
                label += $" (Not in {project.Name})";
            }
            EditorGUI.LabelField(rect, label, style);

            // Draw scene context menu button
            rect.x    += rect.width;
            rect.width = 16;
            if (UnityEngine.GUI.Button(rect, Icons.Settings, GUI.skin.label))
            {
                ShowSceneContextMenu(item);
            }
        }