public int Layout(Rectangle extents, int order, LayoutNode parent) { // Note: Construction is side-effectful: Adds the node to its parent's children. // ReSharper disable once AssignmentIsFullyDiscarded _ = new LayoutNode(parent, this, UiConstants.UiExtents, order); return(order); }
/// <summary> Puts the specified node into a properly flowing container (if it isn't already). </summary> protected virtual LayoutNode PrepareLayout(LayoutNode currentNode, Flow flow) { // Ensures that the node is ready to accept a new node, and returns the parent into which the new node should be inserted LayoutNode parent = currentNode.Parent; switch (flow) { case Flow.Horizontal: if (!(parent is RowNode)) { RowNode rowNode = new RowNode(); rowNode.Children.Add(currentNode); if (parent != null) { parent.Children.Add(rowNode); } return(rowNode); } return(parent); default: if (!(parent is ColumnNode)) { ColumnNode columnNode = new ColumnNode(); columnNode.Children.Add(currentNode); if (parent != null) { parent.Children.Add(columnNode); } return(columnNode); } return(parent); } }
public virtual int Layout(Rectangle extents, int order, LayoutNode parent) { var node = new LayoutNode(parent, this, extents, order); return(DoLayout(extents, order, (child, childExtents, childOrder) => child.Layout(childExtents, childOrder, node))); }
/// <summary> /// 创建节点区域 /// </summary> void CreateLayoutNode() { GUILayout.Space(5); EditorGUILayout.LabelField("Create LayoutNode", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); layoutName = EditorGUILayout.TextField("LayoutName", layoutName); isShow = EditorGUILayout.Toggle("isShow", !isShow); fillType = (LayoutNode.FillType)EditorGUILayout.EnumPopup("FillType", fillType); if (fillType == LayoutNode.FillType.FillParent) { GUI.enabled = false; } EditorGUILayout.BeginHorizontal(); pos = EditorGUILayout.Vector2Field("Pos", pos); size = EditorGUILayout.Vector2Field("Size", size); rotation = EditorGUILayout.Vector3Field("Rotation", rotation); EditorGUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.Space(2); if (GUILayout.Button("Create LayoutNode")) { //EditorApplication.ExecuteMenuItem("PUI/Layout/LayoutNode"); LayoutNode layoutNode = PUITool.CreateGameObject <LayoutNode>(layoutName); layoutNode.rectTransform = layoutNode.gameObject.GetComponent <RectTransform>(); layoutNode.isShow = isShow; layoutNode.fillType = fillType; layoutNode.OnSetRectTransform(pos, size, rotation, fillType); layoutName = "LayoutNode"; } EditorGUILayout.EndVertical(); }
protected void AddLayoutNodeInputs(BuildComponentFactory factory, LayoutNode layoutNode, bool trimTriangles, bool isTopLevel) { if (!isTopLevel && !string.IsNullOrEmpty(layoutNode.ComponentName) && !string.IsNullOrEmpty(layoutNode.ComponentType)) { AddComponentInputs(factory, layoutNode, trimTriangles); } else if (layoutNode is GridLayoutNode) { AddGridInputs(factory, (GridLayoutNode)layoutNode, trimTriangles); } else if (layoutNode is HalfSquareTriangleLayoutNode) { AddHalfSquareTriangleInputs(factory, (HalfSquareTriangleLayoutNode)layoutNode, trimTriangles); } else { var children = new List <Node>(); layoutNode.AddChildrenTo(children); foreach (var child in children) { AddNodeInputs(factory, child, trimTriangles); } } }
public LayoutNode GetLayout() { var rootNode = new LayoutNode(null, null, UiConstants.UiExtents, 0); DoLayout((extents, order, element) => element.Layout(extents, order, new LayoutNode(rootNode, element, extents, order))); return(rootNode); }
public BuildComponentLayout CreateBuildComponentLayout(LayoutNode layoutNode, bool trimTriangles) { m_layoutId += 1; var id = "B." + m_layoutId; return(new BuildComponentLayout(id, layoutNode, trimTriangles)); }
public DividerNode(LayoutNode parent, Texture2D?source = null, Rectangle?sourceRectVert = null, Rectangle?sourceRectHoriz = null) { Parent = parent; Source = source; SourceRectHoriz = sourceRectHoriz; SourceRectVert = sourceRectVert; }
public void NodesWithValues_valueIsTagText() { Layout layout = new Layout("Test Layout", "/Library", new List <LayoutNode>()); LayoutNode rootNode = new LayoutNode("CD Info", "/Library/Disks/CD", true, null, new List <LayoutNode>(), new List <LayoutValue>(), new List <LayoutDataTable>()); rootNode.Values.Add(new LayoutValue("CD Gender", "Gender")); layout.Nodes.Add(rootNode); ModelParser parser = new ModelParser(layout); XmlModel model = parser.parseXmlString(XML_INPUT); Assert.AreEqual(2, model.Nodes.Count); // Instance 1 Assert.AreEqual("CD Info", model.Nodes[0].Description); Assert.AreEqual(false, model.Nodes[0].IsError); Assert.AreEqual(1, model.Nodes[0].Values.Count); Assert.AreEqual("CD Gender", model.Nodes[0].Values[0].Description); Assert.AreEqual("Pop", model.Nodes[0].Values[0].Value); // Instance 2 Assert.AreEqual("CD Info", model.Nodes[1].Description); Assert.AreEqual(false, model.Nodes[1].IsError); Assert.AreEqual(1, model.Nodes[1].Values.Count); Assert.AreEqual("CD Gender", model.Nodes[1].Values[0].Description); Assert.AreEqual("Rock", model.Nodes[1].Values[0].Value); }
private static void AddShapeNodes(IList <ShapeNode> shapeNodes, LayoutNode layoutNode) { foreach (var layoutSite in layoutNode.LayoutSites) { if (layoutSite.Node != null) { AddShapeNodes(shapeNodes, layoutSite.Node); } } }
public void linear_layout_test() { var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), LayoutStyle.Empty, LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)), LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)), LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth()) ); var layoutResult = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult)); }
public void linear_layout_test_with_margin_and_padding() { var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), new LayoutStyle(padding: 5, margin: new Point(3, 6)), LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)), LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)), LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth()) ); var layoutResult = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult)); }
public void fixed_aspect_with_alignment() { var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 80), new LayoutStyle(alignment: Alignment.Center), LayoutNode.Leaf("fixed-aspect", LayoutSize.FixedAspectRatio(16, 9)) ); var firstBakeResult = layout.Bake(); Approvals.Verify( LayoutNodeUtils.DrawResult(firstBakeResult) ); }
public void spacer_test() { var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(50, 20), LayoutStyle.Empty, LayoutNode.StretchedSpacer(), LayoutNode.Leaf("nudged-item", LayoutSize.StretchedVertically(10)), LayoutNode.Spacer(5) ); var firstBakeResult = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult)); }
public void flex_layout_supports_padding() { var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3)), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void can_create_vertical_flex_layout() { var layout = FlexLayout.VerticalFlexParent("root", FlexLayoutStyle.Empty, LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void alignment_with_varied_height_things_top_right() { var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(68, 20), new LayoutStyle(padding: 3, alignment: Alignment.TopRight), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void does_not_stretch_evenly() { var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft), LayoutNode.Leaf("a", LayoutSize.StretchedBoth()), LayoutNode.Leaf("b", LayoutSize.StretchedBoth()), LayoutNode.Leaf("c", LayoutSize.StretchedBoth()) ); var result = layout.Bake(); Approvals.Verify( LayoutNodeUtils.DrawResult(result) ); }
private static void AddLayoutSites(List <LayoutSite> layoutSites, LayoutNode layoutNode) { foreach (var layoutSite in layoutNode.LayoutSites) { if (layoutSite.Node == null || layoutSite.Node is ShapeNode) { layoutSites.Add(layoutSite); } else { AddLayoutSites(layoutSites, layoutSite.Node); } } }
public void flex_can_specify_a_min_width() { var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(minAlongSize: 100, style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void NestedNodesAndValues() { Layout layout = new Layout("Test Layout", "/Library", new List <LayoutNode>()); LayoutNode layoutRoot = new LayoutNode("Library Root", "/Library", true, null, new List <LayoutNode>(), new List <LayoutValue>(), new List <LayoutDataTable>()); LayoutNode disksLayoutNode = new LayoutNode("My Disks", "Disks", true, null, new List <LayoutNode>(), new List <LayoutValue>(), new List <LayoutDataTable>()); LayoutNode cdLayoutNode = new LayoutNode("CD", "CD", true, null, new List <LayoutNode>(), new List <LayoutValue>(), new List <LayoutDataTable>()); LayoutValue artistLayoutValue = new LayoutValue("The Artist", "Artist"); layout.Nodes.Add(layoutRoot); layoutRoot.ChildNodes.Add(disksLayoutNode); disksLayoutNode.ChildNodes.Add(cdLayoutNode); cdLayoutNode.Values.Add(artistLayoutValue); ModelParser parser = new ModelParser(layout); XmlModel model = parser.parseXmlString(XML_INPUT); // Validate root level node Assert.AreEqual(1, model.Nodes.Count, "Checking root level node"); XmlModelNode libraryRoot = model.Nodes[0]; Assert.AreEqual("Library Root", libraryRoot.Description); // Second level node Assert.AreEqual(1, libraryRoot.ChildNodes.Count, "Checking second level node"); XmlModelNode disksLevel = libraryRoot.ChildNodes[0]; Assert.AreEqual("My Disks", disksLevel.Description); // Third level node (two instances of CD) Assert.AreEqual(2, disksLevel.ChildNodes.Count); XmlModelNode cd1 = disksLevel.ChildNodes[0]; XmlModelNode cd2 = disksLevel.ChildNodes[1]; Assert.AreEqual("CD", cd1.Description); Assert.AreEqual("CD", cd2.Description); // Values under the third level node Assert.AreEqual(1, cd1.Values.Count); Assert.AreEqual("The Artist", cd1.Values[0].Description); Assert.AreEqual("Michael Jackson", cd1.Values[0].Value); Assert.AreEqual(1, cd2.Values.Count); Assert.AreEqual("The Artist", cd2.Values[0].Description); Assert.AreEqual("Nirvana", cd2.Values[0].Value); }
public void can_get_baked_layout_node_by_name() { var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft), LayoutNode.Leaf("a", LayoutSize.StretchedBoth()), LayoutNode.Leaf("b", LayoutSize.StretchedBoth()), LayoutNode.Leaf("c", LayoutSize.StretchedBoth()) ); var subject = layout.Bake(); var acquiredNode = subject.GetNode("b"); acquiredNode.Size.Should().Be(new Point(5, 3)); }
public void flex_considers_alignment_when_things_have_varied_perpendicular_size() { var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
private void AddComponentInputs(BuildComponentFactory factory, LayoutNode layoutNode, bool trimTriangles) { var matchingComponent = FindLayout(BuildComponentLayout.CreateStyleKey(layoutNode.ComponentType, layoutNode.ComponentName, layoutNode.GetFabricStyles())); if (matchingComponent != null) { matchingComponent.Quantity += 1; } else { var component = factory.CreateBuildComponentLayout(layoutNode, trimTriangles); AddInput(component); } }
public void flow_layout_supports_horizontal_alignment() { var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 30), new FlowLayoutStyle(alignment: Alignment.CenterRight), LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void flow_layout_can_have_margin() { var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 40), new FlowLayoutStyle(margin: new Point(5)), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void flow_layout_can_have_padding_between_rows() { var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(30, 30), new FlowLayoutStyle(paddingBetweenRows: 3), LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void flow_layout_can_be_vertical() { var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(paddingBetweenItemsInEachRow: 4), LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)), LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void flow_layout_can_be_vertical_with_alignment() { var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(alignment: Alignment.BottomRight), LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)), LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void flow_layout_halts_on_illegal_but_keep_last_overflow() { var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 20), new FlowLayoutStyle(overflowRule: OverflowRule.LastRowKeepsGoing), LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)), LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)), LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 10)), LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)), LayoutNode.Leaf("really-wide-item", LayoutSize.Pixels(21, 10)) ); var result = layout.Bake(); Approvals.Verify(LayoutNodeUtils.DrawResult(result)); }
public void AddConnection(LayoutNode other) { if(m_connections.Count < m_maxConnections) { LayoutConnection newConnection = ScriptableObject.CreateInstance<LayoutConnection>(); newConnection.Source = this; newConnection.Target = other; m_connections.Add(newConnection); other.m_connections.Add(newConnection); } else { Debug.Log("Maximum LayoutNode connections already made"); } }
public void RemoveConnection(LayoutNode other) { LayoutConnection foundConnection = null; foreach(var connection in m_connections) { if(connection.Source == other || connection.Target == other) { foundConnection = connection; break; } } if(foundConnection != null) { m_connections.Remove(foundConnection); other.m_connections.Remove(foundConnection); } }
public override void Initialize() { PNode layoutNode = new LayoutNode(); layoutNode.Brush = Brushes.Red; // add some children to the layout node. for (int i = 0; i < 100; i++) { // create child to add to the layout node. PNode each = PPath.CreateRectangle(0, 0, 100, 80); // add the child to the layout node. layoutNode.AddChild(each); } PBoundsHandle.AddBoundsHandlesTo(layoutNode.GetChild(0)); // add layoutNode to the root so it will be displayed. Canvas.Layer.AddChild(layoutNode); }
private SiteNameNode CreateSiteNodes(Site s) { TreeNode root = sitesTreeView.Nodes[s.FetcherPlugin]; SiteNameNode siteNameNode = new SiteNameNode(s); root.Nodes.Add(siteNameNode); SiteUriNode siteUriNode = new SiteUriNode(s); siteNameNode.Nodes.Add(siteUriNode); LayoutNode layoutNode = new LayoutNode(s); siteNameNode.Nodes.Add(layoutNode); return siteNameNode; }
public void RemoveNode(LayoutNode node) { node.RemoveAllConnections(); m_nodes.Remove(node); }
public void AddNode(LayoutNode node) { m_nodes.Add(node); }
private void ClearDrag() { m_connectionStart = null; m_dragStarted = false; }
public void OnSceneGUI() { Level editorLevel = (Level) target; Event e = Event.current; if(e.type == EventType.KeyDown && e.keyCode == KeyCode.Delete) { if(editorLevel.SelectedNode != null) { editorLevel.RemoveNode(editorLevel.SelectedNode); e.Use(); ClearDrag(); } } if(e.type == EventType.MouseDown && e.button == 1) { ClearDrag(); Debug.Log("Up"); } int idCounter = 1; foreach(var node in editorLevel.Nodes) { Vector3 handlePos = new Vector3(node.m_position.x, node.m_position.y, 0.0f); if(m_mode == EditModes.MoveNodes) { Vector3 newPos = Handles.Slider2D(idCounter, handlePos, new Vector3(0.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), 0.2f, Handles.CubeCap, new Vector2(0.5f, 0.5f)); node.m_position.x = newPos.x; node.m_position.y = newPos.y; ClearDrag(); } else { if(Handles.Button(handlePos, Quaternion.identity, 0.2f, 0.2f, Handles.CubeCap)) { if(!m_dragStarted) { Debug.Log("Click detected"); m_connectionStart = node; m_dragStarted = true; editorLevel.SelectedNode = node; } else { if(node != m_connectionStart) { node.AddConnection(m_connectionStart); ClearDrag(); } } } } // Track whether the slider is selected. if(GUIUtility.hotControl == idCounter) { editorLevel.SelectedNode = node; } // Draw connections foreach(var connection in node.ConnectedNodes) { if(connection.Target != null && connection.Source != null) { Vector3 connectionPos = new Vector3(connection.Target.m_position.x, connection.Target.m_position.y, 0.0f); Handles.DrawLine(handlePos, connectionPos); } } idCounter++; } if(m_dragStarted) { Vector3 startPos = new Vector3(m_connectionStart.m_position.x, m_connectionStart.m_position.y, 0.0f); Plane zeroPlane = new Plane(new Vector3(0.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, 0.0f)); Ray ray = HandleUtility.GUIPointToWorldRay(new Vector2(e.mousePosition.x, e.mousePosition.y)); float hit; if(zeroPlane.Raycast(ray, out hit)) { var hitLocation = ray.GetPoint(hit); Vector3 targetPos = new Vector3(hitLocation.x, hitLocation.y, 0.0f); Handles.DrawLine(startPos, targetPos); HandleUtility.Repaint(); } } DrawGUILayout(); }