Exemplo n.º 1
0
        private void BuildFromNode(ISceneGraphNode node, TreeViewItem parentItem, SearchingScope search)
        {
            TreeViewItem item = null;

            switch (node)
            {
            case EntityNode entityNode:
            {
                item = new EntityItem(m_Session, entityNode.Entity, entityNode.Guid, entityNode);

                if (search.IsSearching)
                {
                    if (search.Map.TryGetValue(entityNode.Entity, out _))
                    {
                        parentItem.AddChild(item);
                    }
                }
                else
                {
                    parentItem.AddChild(item);
                }
            }
            break;
            }

            if (null == item)
            {
                return;
            }

            foreach (var child in node.Children)
            {
                BuildFromNode(child, string.IsNullOrEmpty(m_FilterString) ? item : parentItem, search);
            }
        }
Exemplo n.º 2
0
        public void ShowEntityContextMenu(EntityItem item)
        {
            var menu = new GenericMenu();

            var selection    = GetEntitySelection().ToList();
            var hasSelection = selection.Count > 0;

            if (null != item && item.Entity != Entity.Null)
            {
                menu.AddItem(new GUIContent("Rename"), false, () =>
                {
                    Rename(item.Guid);
                });
            }

            if (hasSelection)
            {
                menu.AddItem(new GUIContent("Duplicate"), false, DuplicateSelection);
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Duplicate"));
            }

            if (hasSelection)
            {
                menu.AddItem(new GUIContent("Delete"), false, DeleteSelection);
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Delete"));
            }

            menu.AddSeparator("");

            //            PopulateEntityTemplate(menu, tree.GetRegistryObjectSelection());
            menu.AddItem(new GUIContent("Empty Entity"), false, () => EntityMenuItems.CreateEmpty());
            menu.AddItem(new GUIContent("Empty Child Entity"), false, () => EntityMenuItems.CreateEmptyChild());
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Audio Source"), false, () => EntityMenuItems.AudioSource(null));
            menu.AddItem(new GUIContent("Camera"), false, () => EntityMenuItems.Camera(null));
            menu.AddItem(new GUIContent("Sprite"), false, () => EntityMenuItems.Sprite(null));
            menu.AddItem(new GUIContent("Canvas"), false, () => EntityMenuItems.UICanvas(null));


            menu.ShowAsContext();
        }
Exemplo n.º 3
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);
            }
        }