コード例 #1
0
 public SquareResizer(TwoPaneSplitView splitView, int dir, float minWidth, Orientation orientation)
 {
     m_Orientation = orientation;
     m_MinWidth    = minWidth;
     m_SplitView   = splitView;
     m_Pane        = splitView.m_FixedPane;
     m_Direction   = dir;
     activators.Add(new ManipulatorActivationFilter {
         button = MouseButton.LeftMouse
     });
     m_Active = false;
 }
コード例 #2
0
        /// <summary>
        /// When the UI is enabled, it sets up all the VisualElement references and loads in the window data.
        /// </summary>
        private void OnEnable()
        {
            //==================================Load Initial Data======================================//
            var uxmlAsset = Resources.Load <VisualTreeAsset>(ResourceAssetPaths.LogicalGraphWindow_UXML);

            uxmlAsset.CloneTree(rootVisualElement);
            m_mainSplitView     = rootVisualElement.Q <UIElements.TwoPaneSplitView>(MAIN_SPLITVIEW);
            m_graphTypeMetadata = new GraphTypeMetadata();
            //=========================================================================================//=

            //==================================Register Toolbar=======================================//
            m_toolbar = rootVisualElement.Q <Toolbar>(TOOLBAR);

            // Save Button
            m_saveGraphButton = new ToolbarButton(() =>
            {
                if (m_openedGraphInstance != null)
                {
                    EditorUtility.SetDirty(m_openedGraphInstance);
                    AssetDatabase.SaveAssets();
                }
            });
            m_saveGraphButton.text = "Save";
            m_toolbar.Add(m_saveGraphButton);
            //=========================================================================================//

            //====================================Register Panels======================================//
            // Left panel is dependent on the right (NodeGraphView) so ordering is important!
            VisualElement mainPanelRight = rootVisualElement.Q <VisualElement>(MAIN_PANEL_RIGHT);
            VisualElement mainPanelLeft  = rootVisualElement.Q <VisualElement>(MAIN_PANEL_LEFT);

            // Populate right panel
            m_nodeGraphView = new NodeGraphView(m_graphTypeMetadata);
            m_nodeGraphView.StretchToParentSize();
            m_nodeGraphView.OnAddToSelection      += OnGraphElementSelectionAdded;
            m_nodeGraphView.OnRemoveFromSelection += OnGraphElementSelectionRemoved;
            m_nodeGraphView.OnClearSelection      += OnGraphElementSelectionCleared;
            mainPanelRight.Add(m_nodeGraphView);

            m_customMenuController = new CustomMenuController(mainPanelRight, m_nodeGraphView);

            // Populate left panel
            List <(string, TabContentElement)> tabs = new List <(string, TabContentElement)>();

            tabs.Add(("Library", m_libraryTab = new LibraryTabElement((string guid) => { OpenGraph(guid); }, m_customMenuController, m_graphTypeMetadata)));
            tabs.Add(("Inspector", m_inspectorTab = new InspectorTabElement(m_nodeGraphView)));
            m_nodeGraphView.OnRemoveNode += (node) => { m_inspectorTab.SetNode(null, null); };
            m_mainTabGroup = new TabGroupElement(tabs);
            m_mainTabGroup.StretchToParentSize();
            m_nodeGraphView.OnMouseClick += () => { m_mainTabGroup.SelectTab(m_inspectorTab); };
            mainPanelLeft.Add(m_mainTabGroup);

            // Other setup
            m_inspectorTab.GraphInspector.OnBlackboardElementChanged += (undoGroup) => { m_nodeGraphView.CallAllNodeViewDrawerBlackboardElementChanged(undoGroup); };
            //=========================================================================================//

            //==================================Callback Listeners=====================================//
            GraphModificationProcessor.OnGraphCreated    += OnNewGraphCreated;
            GraphModificationProcessor.OnGraphWillDelete += OnGraphWillDelete;
            //=========================================================================================//

            // Deserialize the editor window data.
            DeserializeData();
        }