Texture2D GetIconForVFXType(VFXDataType type) { switch (type) { case VFXDataType.SpawnEvent: return(VFXView.LoadImage("Execution")); case VFXDataType.Particle: case VFXDataType.ParticleStrip: // TODO Add an icon return(VFXView.LoadImage("Particles")); } return(null); }
IEnumerable <VFXDataEdge> GetAllEdges() { VFXView view = GetFirstAncestorOfType <VFXView>(); foreach (var edgeController in controller.connections) { VFXDataEdge edge = view.GetDataEdgeByController(edgeController as VFXDataEdgeController); if (edge != null) { yield return(edge); } } }
public void Setup(VFXContextUI initContextUI, VFXView view) { m_Button = this.Query <Button>("system-button"); m_Button.style.backgroundColor = new Color(0.16f, 0.16f, 0.16f); m_Button.clickable.activators.Clear(); m_Button.style.borderBottomColor = m_Button.style.borderTopColor = m_Button.style.borderLeftColor = m_Button.style.borderRightColor = Color.grey * 0.5f; m_Divider = this.Query("divider"); m_TiedContext = initContextUI; m_View = view; m_TiedContext.onSelectionDelegate += OnTiedContextSelection; }
public VFXEdgeDragInfo(VFXView view) { m_View = view; var tpl = VFXView.LoadUXML("VFXEdgeDragInfo"); tpl.CloneTree(this); this.styleSheets.Add(VFXView.LoadStyleSheet("VFXEdgeDragInfo")); m_Text = this.Q <Label>("title"); pickingMode = PickingMode.Ignore; m_Text.pickingMode = PickingMode.Ignore; }
public VFXBlackboard(VFXView view) { m_View = view; editTextRequested = OnEditName; addItemRequested = OnAddItem; this.scrollable = true; SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect)); m_DefaultCategory = new VFXBlackboardCategory() { title = "parameters" }; Add(m_DefaultCategory); m_DefaultCategory.headerVisible = false; styleSheets.Add(Resources.Load <StyleSheet>("VFXBlackboard")); RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown); RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent); RegisterCallback <DragPerformEvent>(OnDragPerformEvent); RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent); RegisterCallback <KeyDownEvent>(OnKeyDown); focusable = true; m_DragIndicator = new VisualElement(); m_DragIndicator.name = "dragIndicator"; m_DragIndicator.style.position = PositionType.Absolute; hierarchy.Add(m_DragIndicator); cacheAsBitmap = true; SetDragIndicatorVisible(false); Resizer resizer = this.Query <Resizer>(); hierarchy.Add(new ResizableElement()); style.position = PositionType.Absolute; subTitle = "Parameters"; resizer.RemoveFromHierarchy(); s_LayoutManual.SetValue(this, false); }
protected virtual void SceneViewGUICallback(UnityObject target, SceneView sceneView) { if (m_CurrentController == null) { return; } var gizmoableAnchors = m_CurrentController.gizmoables; if (gizmoableAnchors.Count > 0) { int current = gizmoableAnchors.IndexOf(m_CurrentController.currentGizmoable); EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUI.enabled = gizmoableAnchors.Count > 1; int result = EditorGUILayout.Popup(current, gizmoableAnchors.Select(t => t.name).ToArray(), GUILayout.Width(100)); GUI.enabled = true; if (EditorGUI.EndChangeCheck() && result != current) { m_CurrentController.currentGizmoable = gizmoableAnchors[result]; } var slotContainer = targets[0] as VFXModel; bool hasvfxViewOpened = VFXViewWindow.currentWindow != null && VFXViewWindow.currentWindow.graphView.controller != null && VFXViewWindow.currentWindow.graphView.controller.graph == slotContainer.GetGraph(); if (m_CurrentController.gizmoIndeterminate) { GUILayout.Label(Contents.gizmoIndeterminateWarning, Styles.warningStyle, GUILayout.Width(19), GUILayout.Height(18)); } else if (m_CurrentController.gizmoNeedsComponent && (!hasvfxViewOpened || VFXViewWindow.currentWindow.graphView.attachedComponent == null)) { GUILayout.Label(Contents.gizmoLocalWarning, Styles.warningStyle, GUILayout.Width(19), GUILayout.Height(18)); } else { if (GUILayout.Button(Contents.gizmoFrame, Styles.frameButtonStyle, GUILayout.Width(19), GUILayout.Height(18))) { if (m_CurrentController != null && VFXViewWindow.currentWindow != null) { VFXView view = VFXViewWindow.currentWindow.graphView; if (view.controller != null && view.controller.model && view.controller.graph == slotContainer.GetGraph()) { sceneView.Frame(m_CurrentController.GetGizmoBounds(view.attachedComponent), false); } } } } GUILayout.EndHorizontal(); } }
private void SelectStickyNotes(VFXView view, List <Experimental.GraphView.GraphElement> elements) { //Select all groups that are new if (firstCopiedStickyNote >= 0) { foreach (var gn in elements.OfType <VFXStickyNote>()) { if (gn.controller.index >= firstCopiedStickyNote) { view.AddToSelection(gn); } } } }
public VFXBlackboard(VFXView view) { m_View = view; editTextRequested = OnEditName; addItemRequested = OnAddItem; this.scrollable = true; SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect)); m_DefaultCategory = new VFXBlackboardCategory() { title = "parameters" }; Add(m_DefaultCategory); m_DefaultCategory.headerVisible = false; AddStyleSheetPath("VFXBlackboard"); RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown); RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent); RegisterCallback <DragPerformEvent>(OnDragPerformEvent); RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent); RegisterCallback <KeyDownEvent>(OnKeyDown); focusIndex = 0; m_DragIndicator = new VisualElement(); m_DragIndicator.name = "dragIndicator"; m_DragIndicator.style.positionType = PositionType.Absolute; shadow.Add(m_DragIndicator); clippingOptions = ClippingOptions.ClipContents; SetDragIndicatorVisible(false); Resizer resizer = this.Query <Resizer>(); shadow.Add(new ResizableElement()); style.positionType = PositionType.Absolute; subTitle = "Parameters"; resizer.RemoveFromHierarchy(); }
public VFXContextUI() : base("uxml/VFXContext") { capabilities |= Capabilities.Selectable | Capabilities.Movable | Capabilities.Deletable | Capabilities.Ascendable; styleSheets.Add(VFXView.LoadStyleSheet("VFXContext")); styleSheets.Add(VFXView.LoadStyleSheet("Selectable")); AddToClassList("VFXContext"); AddToClassList("selectable"); this.mainContainer.style.overflow = Overflow.Visible; m_Divider = this.mainContainer.Q("divider"); m_FlowInputConnectorContainer = this.Q("flow-inputs"); m_FlowOutputConnectorContainer = this.Q("flow-outputs"); m_HeaderIcon = titleContainer.Q <Image>("icon"); m_HeaderSpace = titleContainer.Q <Image>("header-space"); m_HeaderSpace.AddManipulator(new Clickable(OnSpace)); m_BlockContainer = this.Q("block-container"); m_NoBlock = m_BlockContainer.Q("no-blocks"); m_Footer = this.Q("footer"); m_FooterTitle = m_Footer.Q <Label>("title-label"); m_FooterIcon = m_Footer.Q <Image>("icon"); m_DragDisplay = new VisualElement(); m_DragDisplay.AddToClassList("dragdisplay"); m_Label = this.Q <Label>("user-label"); m_TextField = this.Q <TextField>("user-title-textfield"); m_TextField.style.display = DisplayStyle.None; m_Label.RegisterCallback <MouseDownEvent>(OnTitleMouseDown); m_TextField.RegisterCallback <ChangeEvent <string> >(OnTitleChange); m_TextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(OnTitleBlur); m_Label.RegisterCallback <GeometryChangedEvent>(OnTitleRelayout); RegisterCallback <DragUpdatedEvent>(OnDragUpdated); RegisterCallback <DragPerformEvent>(OnDragPerform); RegisterCallback <DragExitedEvent>(OnDragExited); RegisterCallback <DragLeaveEvent>(OnDragExited); }
void PasteBlocks(VFXView view, ref SerializableGraph serializableGraph, List <VFXNodeController> nodesInTheSameOrder) { var selectedContexts = view.selection.OfType <VFXContextUI>().ToArray(); var selectedBlocks = view.selection.OfType <VFXBlockUI>().ToArray(); VFXBlockUI targetBlock = null; VFXContextUI targetContext; if (selectedBlocks.Any()) { targetBlock = selectedBlocks.OrderByDescending(t => t.context.controller.model.GetIndex(t.controller.model)).First(); targetContext = targetBlock.context; } else if (selectedContexts.Length == 1) { targetContext = selectedContexts[0]; } else { Debug.LogWarning(m_BlockPasteError.text); return; } using (new VFXContextUI.GrowContext(targetContext)) { VFXContext targetModelContext = targetContext.controller.model; int targetIndex = -1; if (targetBlock != null) { targetIndex = targetModelContext.GetIndex(targetBlock.controller.model) + 1; } List <VFXBlockController> blockControllers = nodesInTheSameOrder != null ? new List <VFXBlockController>() : null; PasteBlocks(view.controller, serializableGraph.operators, targetModelContext, targetIndex, blockControllers); nodesInTheSameOrder?.AddRange(blockControllers); targetModelContext.Invalidate(VFXModel.InvalidationCause.kStructureChanged); } view.ClearSelection(); foreach (var uiBlock in targetContext.Query().OfType <VFXBlockUI>().Where(t => m_NodesInTheSameOrder.Any(u => u.model == t.controller.model)).ToList()) { view.AddToSelection(uiBlock); } }
void OnSceneGUI(SceneView sv) { try // make sure we don't break the whole scene { var slotContainer = targets[0] as VFXModel; if (VFXViewWindow.currentWindow != null) { VFXView view = VFXViewWindow.currentWindow.graphView; if (view.controller != null && view.controller.model && view.controller.graph == slotContainer.GetGraph()) { if (slotContainer is VFXParameter) { var controller = view.controller.GetParameterController(slotContainer as VFXParameter); m_CurrentController = controller; if (controller != null) { controller.DrawGizmos(view.attachedComponent); } } else { m_CurrentController = view.controller.GetNodeController(slotContainer, 0); } if (m_CurrentController != null) { m_CurrentController.DrawGizmos(view.attachedComponent); if (m_CurrentController.gizmoables.Count > 0) { SceneViewOverlay.Window(new GUIContent("Choose Gizmo"), SceneViewGUICallback, (int)SceneViewOverlay.Ordering.ParticleEffect, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle); } } } else { m_CurrentController = null; } } } catch (System.Exception e) { Debug.LogException(e); } finally { } }
VFXGraph MakeTemporaryGraph() { m_Asset = VisualEffectResource.CreateNewAsset(tempFilePath); VisualEffectResource resource = m_Asset.GetResource(); // force resource creation VFXGraph graph = ScriptableObject.CreateInstance<VFXGraph>(); graph.visualEffectResource = resource; var window = EditorWindow.GetWindow<VFXViewWindow>(); window.Close(); window = EditorWindow.GetWindow<VFXViewWindow>(); m_ViewController = VFXViewController.GetController(m_Asset.GetResource(), true); m_View = window.graphView; m_View.controller = m_ViewController; return graph; }
public void ConvertToSubgraphOperator(VFXView sourceView, IEnumerable <Controller> controllers, Rect rect) { this.m_Rect = rect; Init(sourceView, controllers); if (!CreateUniqueSubgraph("SubgraphOperator", VisualEffectSubgraphOperator.Extension, VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphOperator>)) { return; } CopyPasteNodes(); m_SourceNode = ScriptableObject.CreateInstance <VFXSubgraphOperator>(); PostSetupNode(); m_SourceControllersWithBlocks = m_SourceControllers.Concat(m_SourceControllers.OfType <VFXContextController>().SelectMany(t => t.blockControllers)); TransferEdges(); TransfertOperatorOutputEdges(); Uninit(); }
void DoPaste(VFXViewController viewController, Vector2 center, object data, VFXView view, VFXGroupNodeController groupNode, List <VFXNodeController> nodesInTheSameOrder) { SerializableGraph serializableGraph = (SerializableGraph)data; if (serializableGraph.blocksOnly) { if (view != null) { PasteBlocks(view, ref serializableGraph); } } else { PasteAll(viewController, center, ref serializableGraph, view, groupNode, nodesInTheSameOrder); } }
protected override void OnMouseUp(MouseUpEvent e) { base.OnMouseUp(e); if (!e.isPropagationStopped) { return; } VFXView view = m_Anchor.GetFirstAncestorOfType <VFXView>(); if (view == null) { return; } view.StopEdgeDragInfo(); }
public void CopyPasteSpacableOperator() { var inlineOperatorDesc = VFXLibrary.GetOperators().Where(t => t.modelType == typeof(VFXInlineOperator)).First(); var newOperator = m_ViewController.AddVFXOperator(new Vector2(100, 100), inlineOperatorDesc); newOperator.SetSettingValue("m_Type", new SerializableType(typeof(DirectionType))); m_ViewController.ApplyChanges(); var operatorController = m_ViewController.allChildren.OfType <VFXOperatorController>().First(); Assert.AreEqual(operatorController.model, newOperator); VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; view.controller = m_ViewController; view.ClearSelection(); foreach (var element in view.Query().OfType <GraphElement>().ToList().OfType <ISelectable>()) { view.AddToSelection(element); } VFXSlot aSlot = newOperator.GetInputSlot(0); Assert.IsTrue(aSlot.spaceable); aSlot.space = VFXCoordinateSpace.World; string copyData = view.SerializeElements(view.selection.OfType <GraphElement>()); aSlot.space = VFXCoordinateSpace.Local; view.UnserializeAndPasteElements("paste", copyData); var elements = view.Query().OfType <GraphElement>().ToList(); var copyOperator = elements.OfType <VFXOperatorUI>().First(t => t.controller.model != newOperator); var copyASlot = copyOperator.controller.model.GetInputSlot(0); Assert.AreEqual(VFXCoordinateSpace.World, copyASlot.space); }
public VFXParameterUI() : base("uxml/VFXParameter") { RemoveFromClassList("VFXNodeUI"); styleSheets.Add(VFXView.LoadStyleSheet("VFXParameter")); styleSheets.Add(EditorGUIUtility.Load("StyleSheets/GraphView/Node.uss") as StyleSheet); RegisterCallback <MouseEnterEvent>(OnMouseHover); RegisterCallback <MouseLeaveEvent>(OnMouseHover); m_ExposedIcon = this.Q <Image>("exposed-icon"); m_SuperCollapsedButton = this.Q("super-collapse-button"); m_SuperCollapsedButton.AddManipulator(new Clickable(OnToggleSuperCollapse)); this.AddManipulator(new SuperCollapser()); m_Pill = this.Q("pill"); }
void PasteBlocks(VFXView view, ref SerializableGraph serializableGraph) { var selectedContexts = view.selection.OfType <VFXContextUI>(); var selectedBlocks = view.selection.OfType <VFXBlockUI>(); VFXBlockUI targetBlock = null; VFXContextUI targetContext = null; if (selectedBlocks.Count() > 0) { targetBlock = selectedBlocks.OrderByDescending(t => t.context.controller.model.GetIndex(t.controller.model)).First(); targetContext = targetBlock.context; } else if (selectedContexts.Count() == 1) { targetContext = selectedContexts.First(); } else { Debug.LogError(m_BlockPasteError.text); return; } VFXContext targetModelContext = targetContext.controller.model; int targetIndex = -1; if (targetBlock != null) { targetIndex = targetModelContext.GetIndex(targetBlock.controller.model) + 1; } targetIndex = PasteBlocks(view.controller, serializableGraph.operators, targetModelContext, targetIndex); targetModelContext.Invalidate(VFXModel.InvalidationCause.kStructureChanged); if (view != null) { view.ClearSelection(); foreach (var uiBlock in targetContext.Query().OfType <VFXBlockUI>().Where(t => m_NodesInTheSameOrder.Any(u => u.model == t.controller.model)).ToList()) { view.AddToSelection(uiBlock); } } }
private void FindContextUIsAndSelect(VFXView view, List <Experimental.GraphView.GraphElement> elements) { foreach (var slotContainer in newContexts.Select(t => t.Key).OfType <VFXContext>()) { VFXContextUI contextUI = elements.OfType <VFXContextUI>().FirstOrDefault(t => t.controller.model == slotContainer); if (contextUI != null) { newNodesUI.Add(contextUI); foreach (var block in contextUI.GetAllBlocks().Cast <VFXNodeUI>()) { newNodesUI.Add(block); } newContextUIs.Add(contextUI); view.AddToSelection(contextUI); } } }
public StickyNote(string uiFile, Vector2 position) { var tpl = VFXView.LoadUXML(uiFile); tpl.CloneTree(this); capabilities = Capabilities.Movable | Capabilities.Deletable | Capabilities.Ascendable | Capabilities.Selectable; m_Title = this.Q <Label>(name: "title"); if (m_Title != null) { m_Title.RegisterCallback <MouseDownEvent>(OnTitleMouseDown); } m_TitleField = this.Q <TextField>(name: "title-field"); if (m_TitleField != null) { m_TitleField.style.display = DisplayStyle.None; m_TitleField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnTitleBlur); m_TitleField.RegisterCallback <ChangeEvent <string> >(OnTitleChange); } m_Contents = this.Q <Label>(name: "contents"); if (m_Contents != null) { m_ContentsField = m_Contents.Q <TextField>(name: "contents-field"); if (m_ContentsField != null) { m_ContentsField.style.display = DisplayStyle.None; m_ContentsField.multiline = true; m_ContentsField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnContentsBlur); } m_Contents.RegisterCallback <MouseDownEvent>(OnContentsMouseDown); } SetPosition(new Rect(position, defaultSize)); AddToClassList("sticky-note"); AddToClassList("selectable"); UpdateThemeClasses(); UpdateSizeClasses(); this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); }
protected void OnEnable() { VFXManagerEditor.CheckVFXManager(); if (m_ResourceHistory == null) { m_ResourceHistory = new List <VisualEffectResource>(); } graphView = new VFXView(); graphView.StretchToParentSize(); SetupFramingShortcutHandler(graphView); rootVisualElement.Add(graphView); // make sure we don't do something that might touch the model on the view OnEnable because // the models OnEnable might be called after in the case of a domain reload. m_OnUpdateAction = () => { var currentAsset = GetCurrentResource(); if (currentAsset != null) { LoadResource(currentAsset); } }; autoCompile = true; graphView.RegisterCallback <AttachToPanelEvent>(OnEnterPanel); graphView.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel); if (rootVisualElement.panel != null) { rootVisualElement.AddManipulator(m_ShortcutHandler); } currentWindow = this; #if USE_EXIT_WORKAROUND_FOGBUGZ_1062258 EditorApplication.wantsToQuit += Quitting_Workaround; #endif var icon = AssetDatabase.LoadAssetAtPath <Texture2D>(VisualEffectGraphPackageInfo.assetPackagePath + "/Editor Default Resources/VFX/" + (EditorGUIUtility.isProSkin ? "vfx_graph_icon_gray_dark.png" : "vfx_graph_icon_gray_light.png")); titleContent.image = icon; }
public VFXSaveDropdownButton(VFXView vfxView) : base( vfxView, "VFXSaveDropDownPanel", "Save", "save-button", EditorResources.iconsPath + "SaveActive.png", false, true) { var saveAsButton = m_PopupContent.Q <Button>("saveAs"); saveAsButton.clicked += OnSaveAs; var selectButton = m_PopupContent.Q <Button>("showInInspector"); selectButton.clicked += OnSelectAsset; }
private void SelectGroupNodes(VFXView view, List <Experimental.GraphView.GraphElement> elements) { if (firstCopiedGroup >= 0) { foreach (var gn in elements.OfType <VFXGroupNode>()) { if (gn.controller.index >= firstCopiedGroup) { view.AddToSelection(gn); foreach (var node in gn.containedElements.OfType <VFXNodeUI>()) { newNodesUI.Remove(node); } } } } }
protected void CreateGUI() { rootVisualElement.styleSheets.Add(VFXView.LoadStyleSheet("VFXAttachPanel")); var tpl = VFXView.LoadUXML("VFXAttachPanel"); var mainContainer = tpl.CloneTree(); m_AttachButton = mainContainer.Q <Button>("AttachButton"); m_AttachButton.clicked += OnAttach; var button = mainContainer.Q <Button>("PickButton"); button.clicked += OnPickObject; m_pickedObjectLabel = mainContainer.Q <TextField>("PickLabel"); m_pickedObjectLabel.isReadOnly = true; m_VFXIcon = mainContainer.Q <VisualElement>("VFXIcon"); UpdateAttachedLabel(); rootVisualElement.Add(mainContainer); }
void OnMouseHover(EventBase evt) { VFXView view = GetFirstAncestorOfType <VFXView>(); if (view != null) { foreach (var parameter in view.graphElements.ToList().OfType <VFXParameterUI>().Where(t => t.controller.parentController == controller)) { if (evt.eventTypeId == MouseEnterEvent.TypeId()) { parameter.AddToClassList("hovered"); } else { parameter.RemoveFromClassList("hovered"); } } } }
static VisualEffectObject CreateUniquePath(VFXView sourceView, Type type) { string graphPath = AssetDatabase.GetAssetPath(sourceView.controller.model.asset); string graphName = Path.GetFileNameWithoutExtension(graphPath); string graphDirPath = Path.GetDirectoryName(graphPath); switch (type) { case Type.Operator: { string targetSubgraphPath = string.Format("{0}/{1}_SubgraphOperator.vfxoperator", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_SubgraphOperator_{2}.vfxoperator", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphOperator>(targetSubgraphPath)); } case Type.Context: { string targetSubgraphPath = string.Format("{0}/{1}_Subgraph.vfx", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_Subgraph_{2}.vfx", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNewAsset(targetSubgraphPath)); } case Type.Block: { string targetSubgraphPath = string.Format("{0}/{1}_SubgraphBlock.vfxblock", graphDirPath, graphName); int cpt = 1; while (File.Exists(targetSubgraphPath)) { targetSubgraphPath = string.Format("{0}/{1}_SubgraphBlock_{2}.vfxblock", graphDirPath, graphName, cpt++); } return(VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphBlock>(targetSubgraphPath)); } } return(null); }
private void SelectEdges(VFXView view, List <Experimental.GraphView.GraphElement> elements) { // Simply selected all data edge with the context or slot container, they can be no other than the copied ones foreach (var dataEdge in elements.OfType <VFXDataEdge>()) { if (newNodesUI.Contains(dataEdge.input.GetFirstAncestorOfType <VFXNodeUI>())) { view.AddToSelection(dataEdge); } } // Simply selected all data edge with the context or slot container, they can be no other than the copied ones foreach (var flowEdge in elements.OfType <VFXFlowEdge>()) { if (newContextUIs.Contains(flowEdge.input.GetFirstAncestorOfType <VFXContextUI>())) { view.AddToSelection(flowEdge); } } }
void OnAttachToPanel(AttachToPanelEvent e) { m_View = GetFirstAncestorOfType <VFXView>(); if (m_View == null) { VisualElement current = this; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("Send tristan this error"); while (current != null) { sb.AppendLine(current.GetType().Name + " " + current.name); current = current.parent; } Debug.LogError(sb.ToString()); return; } m_View.allDataAnchors.Add(this); }
protected void SetupFramingShortcutHandler(VFXView view) { m_ShortcutHandler = new ShortcutHandler( new Dictionary <Event, ShortcutDelegate> { { Event.KeyboardEvent("a"), view.FrameAll }, { Event.KeyboardEvent("f"), view.FrameSelection }, { Event.KeyboardEvent("o"), view.FrameOrigin }, { Event.KeyboardEvent("^#>"), view.FramePrev }, { Event.KeyboardEvent("^>"), view.FrameNext }, { Event.KeyboardEvent("#^r"), view.Resync }, { Event.KeyboardEvent("F7"), view.Compile }, { Event.KeyboardEvent("#d"), view.OutputToDot }, { Event.KeyboardEvent("^#d"), view.OutputToDotReduced }, { Event.KeyboardEvent("#c"), view.OutputToDotConstantFolding }, { Event.KeyboardEvent("^r"), view.ReinitComponents }, { Event.KeyboardEvent("F5"), view.ReinitComponents }, }); }
public static bool ValidatePosition(GraphElement element, VFXView view, Rect defaultPosition) { Rect viewrect = view.contentRect; Rect rect = element.GetPosition(); bool changed = false; if (!viewrect.Contains(rect.position)) { Vector2 newPosition = defaultPosition.position; if (!viewrect.Contains(defaultPosition.position)) { newPosition = sizeMargin; } rect.position = newPosition; changed = true; } Vector2 maxSizeInView = viewrect.max - rect.position - sizeMargin; float newWidth = Mathf.Max(element.resolvedStyle.minWidth.value, Mathf.Min(rect.width, maxSizeInView.x)); float newHeight = Mathf.Max(element.resolvedStyle.minHeight.value, Mathf.Min(rect.height, maxSizeInView.y)); if (Mathf.Abs(newWidth - rect.width) > 1) { rect.width = newWidth; changed = true; } if (Mathf.Abs(newHeight - rect.height) > 1) { rect.height = newHeight; changed = true; } if (changed) { element.SetPosition(rect); } return(false); }