public Blackboard(VisualElement visualParent, GraphView graph) { m_visualParent = visualParent; UnityEditor.Experimental.GraphView.Blackboard bb = new UnityEditor.Experimental.GraphView.Blackboard(graph); //bb.subTitle = string.Empty; //m_visualParent.Add(bb); graph.Add(bb); bb.title = "Test Blackboard"; BlackboardSection bbSection = new BlackboardSection(); bbSection.title = "Section Test Name"; bbSection.headerVisible = true; bb.Add(bbSection); BlackboardField bbField = new BlackboardField(); bbField.title = "TestVariable"; bbField.text = "TestText"; //bbSection.Add(bbField); BlackboardRow bbRow = new BlackboardRow(bbField, new VisualElement()); bbSection.Add(bbRow); bbSection.Add(bbRow); Debug.Log($"Is Field Droppable {bbField.IsDroppable()}"); }
private void AddErrorToolbar() { if (m_ErrorToolbar != null) { GraphView.Add(m_ErrorToolbar); } }
protected GraphSubWindow(GraphView associatedGraphView = null) : base() { m_GraphView = associatedGraphView; m_GraphView.Add(this); // Setup VisualElement from Stylesheet and UXML file styleSheets.Add(Resources.Load <StyleSheet>($"Styles/{styleName}")); var uxml = Resources.Load <VisualTreeAsset>($"UXML/{UxmlName}"); m_MainContainer = uxml.Instantiate(); m_MainContainer.AddToClassList("mainContainer"); m_Root = m_MainContainer.Q("content"); m_HeaderItem = m_MainContainer.Q("header"); m_HeaderItem.AddToClassList("subWindowHeader"); m_TitleLabel = m_MainContainer.Q <Label>(name: "titleLabel"); m_SubTitleLabel = m_MainContainer.Q <Label>(name: "subTitleLabel"); m_ContentContainer = m_MainContainer.Q(name: "contentContainer"); hierarchy.Add(m_MainContainer); capabilities |= Capabilities.Movable | Capabilities.Resizable; style.overflow = Overflow.Hidden; focusable = false; m_Scrollable = true; HandleScrollingBehavior(m_Scrollable); name = elementName; title = windowTitle; ClearClassList(); AddToClassList(name); BuildManipulators(); /* Event interception to prevent GraphView manipulators from being triggered */ RegisterCallback <DragUpdatedEvent>(e => { e.StopPropagation(); }); // prevent Zoomer manipulator RegisterCallback <WheelEvent>(e => { e.StopPropagation(); }); RegisterCallback <MouseDownEvent>(e => { if (e.button == (int)MouseButton.LeftMouse) { ClearSelection(); } // prevent ContentDragger manipulator e.StopPropagation(); }); }
private void CreateBlackBoard(GraphView graph) { var blackboard = new Blackboard(graph); blackboard.Add(new BlackboardSection { title = "Dialogue Properties" }); blackboard.addItemRequested = BuildBlackboardMenu; blackboard.SetPosition(new Rect(10, 30, 200, 300)); graph.Add(blackboard); }
private static void LinkPort(GraphView view, Port source, Port target) { var edge = new Edge { output = source, input = target, }; edge.input.Connect(edge); edge.output.Connect(edge); view.Add(edge); }
private void ShowWarningLabel(string content) { if (m_GraphView == null) { return; } CreateWarningLabel(); if (m_WarningLabel.parent != m_GraphView) { m_GraphView.Add(m_WarningLabel); } m_WarningLabel.text = content; }
internal void BeginSnap(GraphView graphView) { if (m_Service == null) { m_Service = new SnapService(); } if (m_LineView == null) { m_LineView = new LineView(); } m_GraphView = graphView; m_GraphView.Add(m_LineView); m_LineView.layout = new Rect(0, 0, m_GraphView.layout.width, m_GraphView.layout.height); var notSelectedElementRects = GetNotSelectedElementRectsInView(); m_Service.BeginSnap(notSelectedElementRects); }
protected virtual void OnEnable() { // When we open a window (including when we start the Editor), a new GUID is assigned. // When a window is opened and there is a domain reload, the GUID stays the same. if (m_GUID == default) { m_GUID = SerializableGUID.Generate(); } var initialState = CreateInitialState(); CommandDispatcher = new CommandDispatcher(initialState); PluginRepository = new PluginRepository(this); rootVisualElement.Clear(); rootVisualElement.pickingMode = PickingMode.Ignore; m_GraphContainer = new VisualElement { name = "graphContainer" }; m_GraphView = CreateGraphView(); m_MainToolbar = CreateMainToolbar(); m_ErrorToolbar = CreateErrorToolbar(); m_BlankPage = CreateBlankPage(); m_BlankPage?.CreateUI(); if (m_MainToolbar != null) { rootVisualElement.Add(m_MainToolbar); } // AddTracingTimeline(); rootVisualElement.Add(m_GraphContainer); if (m_ErrorToolbar != null) { m_GraphView.Add(m_ErrorToolbar); } m_GraphContainer.Add(m_GraphView); rootVisualElement.name = "gtfRoot"; rootVisualElement.AddStylesheet("GraphViewWindow.uss"); // PF FIXME: Use EditorApplication.playModeStateChanged / AssemblyReloadEvents ? Make sure it works on all domain reloads. // After a domain reload, all loaded objects will get reloaded and their OnEnable() called again // It looks like all loaded objects are put in a deserialization/OnEnable() queue // the previous graph's nodes/edges/... might be queued AFTER this window's OnEnable // so relying on objects to be loaded/initialized is not safe // hence, we need to defer the loading command rootVisualElement.schedule.Execute(() => { var lastGraphFilePath = CommandDispatcher.State.WindowState.LastOpenedGraph.GetGraphAssetModelPath(); var lastGraphId = CommandDispatcher.State.WindowState.LastOpenedGraph.AssetLocalId; if (!string.IsNullOrEmpty(lastGraphFilePath)) { try { CommandDispatcher.Dispatch(new LoadGraphAssetCommand( lastGraphFilePath, lastGraphId, PluginRepository, CommandDispatcher.State.WindowState.LastOpenedGraph.BoundObject, LoadGraphAssetCommand.LoadStrategies.KeepHistory)); } catch (Exception e) { Debug.LogError(e); } } }).ExecuteLater(0); m_GraphProcessingPendingLabel = new Label("Graph Processing Pending") { name = "graph-processing-pending-label" }; if (WithSidePanel) { m_SidePanel = CreateModelInspectorView(); } if (m_SidePanel != null) { m_GraphContainer.Add(m_SidePanel); } rootVisualElement.RegisterCallback <AttachToPanelEvent>(OnEnterPanel); rootVisualElement.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel); // that will be true when the window is restored during the editor startup, so OnEnterPanel won't be called later if (rootVisualElement.panel != null) { OnEnterPanel(null); } titleContent = new GUIContent("Graph Tool"); m_LockTracker.lockStateChanged.AddListener(OnLockStateChanged); m_AutomaticGraphProcessor = new AutomaticGraphProcessor(PluginRepository); CommandDispatcher.RegisterObserver(m_AutomaticGraphProcessor); rootVisualElement.RegisterCallback <MouseMoveEvent>(ResetGraphProcessorTimer); m_GraphProcessingStatusObserver = new GraphProcessingStatusObserver(m_GraphProcessingPendingLabel, m_ErrorToolbar); CommandDispatcher.RegisterObserver(m_GraphProcessingStatusObserver); m_SidePanelObserver = new SidePanelObserver(this); CommandDispatcher.RegisterObserver(m_SidePanelObserver); }
public void OnDrop(GraphView graphView, Edge edge) { edge.output.Connect(edge); edge.input.Connect(edge); graphView.Add(edge); }