public void AddSearchWindow(StrategyGraphViewWIndow editorWindow) { _searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); _searchWindow.Configure(editorWindow, this); nodeCreationRequest = context => SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), _searchWindow); }
private void GenerateSearchWindow() { _searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); _searchWindow.Init(_graphView, this); //侦听创建节点请求事件,空格键或右键 _graphView.nodeCreationRequest = ctx => SearchWindow.Open(new SearchWindowContext(ctx.screenMousePosition), _searchWindow); }
private void AddSearchWindow(EditorWindow editorWindow) { _searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); _searchWindow.Init(editorWindow, this); nodeCreationRequest = context => SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), _searchWindow); }
public void OnDropOutsidePort(Edge edge, Vector2 position) { var draggedPort = (edge.output != null ? edge.output.edgeConnector.edgeDragHelper.draggedPort : null) ?? (edge.input != null ? edge.input.edgeConnector.edgeDragHelper.draggedPort : null); m_SearchWindowProvider.connectedPort = (ShaderPort)draggedPort; SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), m_SearchWindowProvider); }
private void OnCreateNode(NodeCreationContext context) { var windowContext = new SearchWindowContext(context.screenMousePosition, SearchWindowWidth, SearchWindowHeight); SearchWindow.Open(windowContext, m_searchWindowProvider); }
private void SelectState() { var searchWindow = ScriptableObject.CreateInstance <StateSearchWindow>(); searchWindow.Init(this, FSMGraphView.AvailableStates); SearchWindow.Open(new SearchWindowContext(), searchWindow); }
/// <summary> /// 初期化 /// </summary> private void Init() { // 親のサイズに合わせてGraphViewのサイズを設定 this.StretchToParentSize(); // ズームインアウト SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); // ドラッグで描画範囲を移動 this.AddManipulator(new ContentDragger()); // ドラッグで選択した要素を移動 this.AddManipulator(new SelectionDragger()); // ドラッグで範囲選択 this.AddManipulator(new RectangleSelector()); // ussファイルを読み込んでスタイルに追加 this.styleSheets.Add(Resources.Load <StyleSheet>("GraphViewBackGround")); // 背景を一番後ろに追加 this.Insert(0, new GridBackground()); this.graphViewChanged += OnGraphViewChanged; // 右クリックでノード作成するウィンドウ追加 var searchWindowProvider = ScriptableObject.CreateInstance <ScriptGraphSearchWindowProvider>(); searchWindowProvider.Init(this, _window, OnCreatedNode, OnNodeContentChanged); this.nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), searchWindowProvider); }; }
public PickerControl() { _button = new Button(); _button.AddToClassList(ButtonUssClassName); _button.AddToClassList(BasePopupField <ValueType, ValueType> .inputUssClassName); _button.clicked += () => { if (_provider) { SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(new Vector2(worldBound.center.x, worldBound.yMax + worldBound.height - 4)), worldBound.width), _provider); } }; _icon = new Image { pickingMode = PickingMode.Ignore }; _icon.AddToClassList(IconUssClassName); _label = new TextElement { pickingMode = PickingMode.Ignore }; _label.AddToClassList(InputLabelUssClassName); _arrow = new VisualElement { pickingMode = PickingMode.Ignore }; _arrow.AddToClassList(BasePopupField <ValueType, ValueType> .arrowUssClassName); _button.Add(_icon); _button.Add(_label); _button.Add(_arrow); Add(_button); }
private void TryOpenFocusedSearch() { if (SearchWindow.Open(new SearchWindowContext(_searchWindowPosition, 360, 360), _focusedSearchWindow)) { EditorApplication.update -= TryOpenFocusedSearch; } }
public ExampleGraphView(EditorWindow editorWindow) { // ノードを追加 AddElement(new ExampleNode()); // 親のサイズに合わせてGraphViewのサイズを設定 this.StretchToParentSize(); // MMBスクロールでズームインアウトができるように SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); // MMBドラッグで描画範囲を動かせるように this.AddManipulator(new ContentDragger()); // LMBドラッグで選択した要素を動かせるように this.AddManipulator(new SelectionDragger()); // LMBドラッグで範囲選択ができるように this.AddManipulator(new RectangleSelector()); // 右クリックメニューを追加 var menuWindowProvider = ScriptableObject.CreateInstance <SearchMenuWindowProvider>(); menuWindowProvider.Initialize(this, editorWindow); nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), menuWindowProvider); }; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); string addressableType = "SoundAndMusic"; var Path = property.FindPropertyRelative("AssetAddress"); string stringpath = Path.stringValue; if (string.IsNullOrEmpty(stringpath)) { stringpath = "Null"; } Rect labelposition = position; Rect buttonposition = position; labelposition.xMax -= 150; buttonposition.xMin += 150; EditorGUI.LabelField(labelposition, $"{property.displayName}"); // EditorGUILayout.LabelField($"{property.displayName}", GUILayout.ExpandWidth(false), ; if (GUI.Button(buttonposition, $"{stringpath}", EditorStyles.popup)) { SearchWindow.Open( new SearchWindowContext(GUIUtility.GUIToScreenPoint((UnityEngine.Event.current.mousePosition))), new StringSearchList(AddressablePicker.options[addressableType], s => { Path.stringValue = s; Path.serializedObject.ApplyModifiedProperties(); })); } EditorGUI.EndProperty(); }
public CodeGraphView(CodeGraph editorWindow) { this.editorWindow = editorWindow; this.AddStyleSheet("CodeGraph"); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); this.AddManipulator(new ContentDragger()); this.AddManipulator(new SelectionDragger()); this.AddManipulator(new RectangleSelector()); this.AddManipulator(new FreehandSelector()); var grid = new GridBackground(); Insert(0, grid); grid.StretchToParentSize(); var searchWindowProvider = ScriptableObject.CreateInstance <SearchWindowProvider>(); searchWindowProvider.Initialize(this.editorWindow, this); nodeCreationRequest = c => SearchWindow.Open(new SearchWindowContext(c.screenMousePosition), searchWindowProvider); graphViewChanged += OnGraphViewChanged; serializeGraphElements += SerializeGraphElementsImplementation; // canPasteSerializedData = CanPasteSerializedDataImplementation; unserializeAndPaste += UnserializeAndPasteImplementation; // deleteSelection = DeleteSelectionImplementation; }
public ExampleGraphView(EditorWindow editor, ref GraphAsset asset) { graphAsset = asset; editorWindow = editor; //AddElement(new ExampleNode()); //ノードの追加 //諸々の設定 this.StretchToParentSize(); contentDragger = new ContentDragger(); selectionDragger = new SelectionDragger(); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); this.AddManipulator(new ContextualMenuManipulator(OnContextMenuPopulate)); this.AddManipulator(contentDragger); this.AddManipulator(selectionDragger); //this.AddManipulator(new RectangleSelector()); //右クリックでのメニューの表示 searchWindow = ScriptableObject.CreateInstance <SearchMenuWindow>(); searchWindow.Init(this, editor, ref graphAsset); nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), searchWindow); }; }
public void OpenVariableSearch(Vector2 screenMousePosition) { // offset search window to appear next to mouse screenMousePosition.x += 140; screenMousePosition.y += 0; SearchWindow.Open(new SearchWindowContext(screenMousePosition, 360, 360), _variableSearchWindow); }
public RootSOTreeView(RootSO rootSO, EditorWindow editor) { _rootSO = rootSO; style.flexGrow = 1; style.flexShrink = 1; SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); Insert(0, new GridBackground()); var contentDragger = new ContentDragger(); //default activator requires Alt key. Alt key is tired. contentDragger.activators.Add(new ManipulatorActivationFilter() { button = MouseButton.LeftMouse, }); // item dragging is prior to view dragging. this.AddManipulator(new SelectionDragger()); this.AddManipulator(contentDragger); var provider = ScriptableObject.CreateInstance <NodeSearchWindowProvider>(); provider.Initialize(this, editor); nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), provider); }; }
public void OnDropOutsidePort(UnityEditor.Experimental.GraphView.Edge edge, Vector2 position) { var draggedPort = edge.output?.edgeConnector.edgeDragHelper.draggedPort ?? edge.input?.edgeConnector.edgeDragHelper.draggedPort; m_SearchWindowProvider.connectedPort = (NodePort)draggedPort; SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), m_SearchWindowProvider); }
// Generate node creation toolbar private void GenerateNodeToolbar() { Toolbar toolbar = new Toolbar(); // Behaviour name field TextField behaviourNameField = new TextField(); behaviourNameField.label = "Behaviour Name: "; behaviourNameField.labelElement.style.color = Color.black; behaviourNameField.SetValueWithoutNotify(_newBehaviourName); behaviourNameField.MarkDirtyRepaint(); behaviourNameField.RegisterValueChangedCallback(evt => _newBehaviourName = evt.newValue); toolbar.Add(behaviourNameField); // Create new node menu ToolbarMenu menu = new ToolbarMenu(); menu.text = "Create New Behaviour"; menu.menu.AppendAction("New Behaviour", x => { _graphView.CreateNewNode(_newBehaviourName, NodeTypes.Action); }); menu.menu.AppendAction("New Composite", x => { _graphView.CreateNewNode(_newBehaviourName, NodeTypes.Composite); }); menu.menu.AppendAction("New Decorator", x => { _graphView.CreateNewNode(_newBehaviourName, NodeTypes.Decorator); }); toolbar.Add(menu); Button button = new Button(() => { SearchWindow.Open(new SearchWindowContext(mouseOverWindow.position.position), _graphView._addNodeSearchWindow); }); button.text = "Add existing node"; toolbar.Add(button); rootVisualElement.Add(toolbar); }
public GraphViewExample() : base() { //ノードをドラッグ出来るようにする this.AddManipulator(new SelectionDragger()); var graphviewProvider = new GraphViewProviderExample(); graphviewProvider.Initialize(this); //右クリックでノードを作成できるようにする nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), graphviewProvider); }; //GraphViewの背景を黒っぽくする Addだと手前に表示されるためInsertで差し込む Insert(0, new GridBackground()); //拡大縮小 SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); startNode = new StartNode(); //開始ノードを最初から作成しておく AddElement(startNode); }
public GraphEditorView(EditorWindow editorWindow, AbstractMaterialGraph graph, string assetName) { m_Graph = graph; AddStyleSheetPath("Styles/MaterialGraph"); previewManager = new PreviewManager(graph); var content = new VisualElement { name = "content" }; { m_GraphView = new MaterialGraphView(graph) { name = "GraphView", persistenceKey = "MaterialGraphView" }; m_GraphView.SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); m_GraphView.AddManipulator(new ContentDragger()); m_GraphView.AddManipulator(new SelectionDragger()); m_GraphView.AddManipulator(new RectangleSelector()); m_GraphView.AddManipulator(new ClickSelector()); m_GraphView.AddManipulator(new GraphDropTarget(graph)); content.Add(m_GraphView); m_GraphInspectorView = new GraphInspectorView(assetName, previewManager, graph) { name = "inspector" }; m_GraphInspectorView.AddManipulator(new Draggable(OnMouseDrag, true)); m_GraphView.RegisterCallback <PostLayoutEvent>(OnPostLayout); m_GraphInspectorView.RegisterCallback <PostLayoutEvent>(OnPostLayout); m_GraphView.Add(m_GraphInspectorView); m_GraphView.graphViewChanged = GraphViewChanged; } m_SearchWindowProvider = ScriptableObject.CreateInstance <SearchWindowProvider>(); m_SearchWindowProvider.Initialize(editorWindow, m_Graph, m_GraphView); m_GraphView.nodeCreationRequest = (c) => { m_SearchWindowProvider.connectedPort = null; SearchWindow.Open(new SearchWindowContext(c.screenMousePosition), m_SearchWindowProvider); }; m_EdgeConnectorListener = new EdgeConnectorListener(m_Graph, m_SearchWindowProvider); foreach (var node in graph.GetNodes <INode>()) { AddNode(node); } foreach (var edge in graph.edges) { AddEdge(edge); } Add(content); }
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) { evt.menu.MenuItems().Add(new BehaviorTreeDropdownMenuAction("Change Behavior", (a) => { var provider = new ActionSearchWindowProvider(this); SearchWindow.Open(new SearchWindowContext(evt.localMousePosition), provider); })); }
private void ShowGraphPicker(Vector2 position) { var graphs = AssetHelper.GetAssetList <Graph>(); _graphProvider.Setup("Select Graph", graphs.Paths, graphs.Assets.Cast <Graph>().ToList(), graph => AssetPreview.GetMiniThumbnail(graph), selectedGraph => SetGraph(selectedGraph)); SearchWindow.Open(new SearchWindowContext(position), _graphProvider); }
void InitializeGraphView() { graph.onExposedParameterListChanged += () => onExposedParameterListChanged?.Invoke(); graph.onExposedParameterModified += (s) => onExposedParameterModified?.Invoke(s); viewTransform.position = graph.position; viewTransform.scale = graph.scale; nodeCreationRequest = (c) => SearchWindow.Open(new SearchWindowContext(c.screenMousePosition), createNodeMenu); }
public UIRelationGraphView() { styleSheets.Add(Resources.Load <StyleSheet>("NarrativeGraph")); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); this.AddManipulator(new ContentDragger()); this.AddManipulator(new SelectionDragger()); this.AddManipulator(new RectangleSelector()); this.AddManipulator(new FreehandSelector()); var grid = new GridBackground(); Insert(0, grid); grid.StretchToParentSize(); var provider = ScriptableObject.CreateInstance <UIViewMenuWindowProvider>(); provider.CreateNodeEvent += configuration => { foreach (var existNode in m_nodes) { if (existNode.Configuration == configuration) { return(false); } } var node = new UINextLinkNode(configuration); AddNewNode(node); return(true); }; nodeCreationRequest += context => { if (m_sourceNode == null) { return; } SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), provider); }; graphViewChanged += change => { if (change.elementsToRemove == null) { return(change); } foreach (var element in change.elementsToRemove) { if (element is UINextLinkNode linkNode) { m_nodes.RemoveSwap(linkNode); RefreshPosition(); } else if (element is Edge edge) { m_edges.RemoveSwap(edge); } } return(change); }; }
private void AddSearchWindow(EditorWindow editorWindow) { //get data provider _searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); //and the graph view to searchwindow _searchWindow.Init(editorWindow, this); //sub to the graph api and open window nodeCreationRequest = context => SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), _searchWindow); }
private void AddSearchWindow(DialogueGraph editorWindow) { searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); searchWindow.Configure(editorWindow, this); nodeCreationRequest = context => SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), searchWindow); searchWindow.tree = CreateMenuOptions(); }
private void AddSearchWindow() { searchWindow = ScriptableObject.CreateInstance <NodeSearchWindow>(); searchWindow.CreateSearchWindow(this); nodeCreationRequest = ctx => { SearchWindow.Open(new SearchWindowContext(ctx.screenMousePosition), searchWindow); }; }
void InitializeCallbacks() { graphViewChanged = GraphViewChangedCallback; viewTransformChanged = ViewTransformChangedCallback; CreateNodeMenu = ScriptableObject.CreateInstance <CreateNodeMenuWindow>(); CreateNodeMenu.Initialize(this, GetNodeTypes()); nodeCreationRequest = c => SearchWindow.Open(new SearchWindowContext(c.screenMousePosition), CreateNodeMenu); }
public void OpenPortSearch(Type type, Vector2 screenMousePosition, Port port, Direction direction) { // offset search window to appear next to mouse screenMousePosition.x += 140; screenMousePosition.y += 0; _portSearchWindow.typeToSearch = type; _portSearchWindow.startingPort = port; _portSearchWindow.direction = direction; SearchWindow.Open(new SearchWindowContext(screenMousePosition, 360, 360), _portSearchWindow); }
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) { evt.menu.MenuItems().Add(new BehaviorTreeDropdownMenuAction("Change Behavior", (a) => { var provider = new CompositeSearchWindowProvider(this); SearchWindow.Open(new SearchWindowContext(evt.localMousePosition), provider); })); evt.menu.MenuItems().Add(new BehaviorTreeDropdownMenuAction("Add Child", (a) => AddChild())); evt.menu.MenuItems().Add(new BehaviorTreeDropdownMenuAction("Remove Unnecessary Children", (a) => RemoveUnnecessaryChildren())); }
void ShowNodeCreationMenuFromEdge(EdgeView edgeView, Vector2 position) { if (edgeNodeCreateMenuWindow == null) { edgeNodeCreateMenuWindow = ScriptableObject.CreateInstance <CreateNodeMenuWindow>(); } edgeNodeCreateMenuWindow.Initialize(graphView, EditorWindow.focusedWindow, edgeView); SearchWindow.Open(new SearchWindowContext(position + EditorWindow.focusedWindow.position.position), edgeNodeCreateMenuWindow); }