public BonsaiInput()
        {
            // Clicks are one-shot events.
            clickTimer.AutoReset = false;

            // Setup Node Selection menu.
            foreach (var kvp in BonsaiEditor.Behaviours)
            {
                Type nodeType = kvp.Key;
                BonsaiEditor.NodeTypeProperties prop = kvp.Value;
                nodeTypeSelectionMenu.AddItem(new GUIContent(prop.path), false, OnCreateNodeRequest, nodeType);
            }

            // Setup node context menu.
        }
Ejemplo n.º 2
0
        public BonsaiInputHandler(BonsaiWindow w)
        {
            _window = w;
            _nodeTypeSelectionMenu = new GenericMenu();
            _nodeContextMenu       = new GenericMenu();
            _multiNodeContextMenu  = new GenericMenu();

            // Setup Node Selection menu.
            foreach (var kvp in BonsaiEditor.Behaviours)
            {
                Type nodeType = kvp.Key;
                BonsaiEditor.NodeTypeProperties prop = kvp.Value;

                _nodeTypeSelectionMenu.AddItem(new GUIContent(prop.path), false, onNodeCreateCallback, nodeType);
            }

            // Setup node context menu.
            _nodeContextMenu.AddItem(new GUIContent("Set As Root"), false, onNodeContextCallback, NodeContext.SetAsRoot);
            _nodeContextMenu.AddItem(new GUIContent("Duplicate"), false, onNodeContextCallback, NodeContext.Duplicate);
            _nodeContextMenu.AddItem(new GUIContent("Change Type"), false, onNodeContextCallback, NodeContext.ChangeType);
            _nodeContextMenu.AddItem(new GUIContent("Delete"), false, onNodeContextCallback, NodeContext.Delete);

            // Setup area selection context menu.
            _multiNodeContextMenu.AddItem(new GUIContent("Duplicate"), false, onMultiNodeCallback, NodeContext.DuplicateSelection);
            _multiNodeContextMenu.AddItem(new GUIContent("Delete"), false, onMultiNodeCallback, NodeContext.DeleteSelection);

            // Define the actions to take when a single node is selected.
            onSingleSelected = (node) =>
            {
                // Only apply single node selection on a node that is
                // not currently under area selection.
                if (!node.bAreaSelectionFlag)
                {
                    _window.editor.ClearReferencedNodes();
                    clearAreaSelection();

                    _selectedNode = node;
                    _window.editor.canvas.PushToEnd(_selectedNode);
                    Selection.activeObject = node.behaviour;

                    handleOnAborterSelected(node);
                    handleOnReferenceContainerSelected(node);
                }
            };
        }