Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Vectrosity - Fast and Easy Line Drawing

Discussion in 'Assets and Asset Store' started by Eric5h5, Sep 26, 2014.

  1. MylesLambert

    MylesLambert

    Joined:
    Dec 31, 2012
    Posts:
    61
    Hello!
    Firstly thanks so much for supporting Vectrosity for so long :)
    I'm running into an issue where lines are being destroyed when the scene is being unloaded. I'd like to manage the lifetime of the line myself but can't seem to access the GameObject to set DontDestroyOnLoad.
    I'm using "VectorLine.SetLine3D(Color.white, new Vector3[steps])" to create the line.

    Apologies if I missed something in the documentation, I only see references to the canvas object which I'm not using.
    Thanks!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can do

    Code (csharp):
    1. someLine = VectorLine.SetLine3D(Color.white, new Vector3[steps];
    2. DontDestroyOnLoad(someLine.drawTransform.gameObject);
    --Eric
     
    MylesLambert likes this.
  3. MylesLambert

    MylesLambert

    Joined:
    Dec 31, 2012
    Posts:
    61
    Yeah did try drawTransform but it is throwing null for me, could be I'm using an old version since I haven't needed to update.
    Will update and try again.

    EDIT:
    Updated to latest, the following still throws null for me,

    Code (CSharp):
    1. trajectoryLine = VectorLine.SetLine3D(Color.white, new Vector3[steps]);
    2. Debug.Log(trajectoryLine.drawTransform);
    EDIT:
    Never mind, since updating to latest which replaced the DLL it was easier to resolve by just exposing the GameObject directly.
    Thanks!
     
    Last edited: Dec 19, 2021
  4. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
    So Im surprised you're still offering help for this asset you made so long ago. But I have had question.

    I am using Vectrosity to make lines for lasers in my game, I've been trying to give them a little more aesthetic so Im wondering if theres a way to make rays with materials and line thickness? Maybe the ability for them to follow the origin if it moves?

    I'm just using basic SetRay3D atm
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not entirely sure what you mean, but you have more control over lines if you create them using the constructor. i.e., myLine = new VectorLine(...). You can set a material that way, or use VectorLine.material.

    --Eric
     
  6. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    19
    I guess my main problem is Width scaling to screen(?)


    https://i.gyazo.com/2c41ecb42b77039530d1bef8804b76af.mp4

    Code (CSharp):
    1.             List<Vector3> points = new List<Vector3> {
    2.                 transform.position, transform.position + transform.forward * range };
    3.             VectorLine myLine = new VectorLine("tacheon Blast", points, laser, 100f, LineType.Continuous);
    4.             myLine.Draw3DAuto();
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well, that's the feature of Vectrosity where it maintains a constant pixel width, so it's probably not the best for that sort of thing. You could manually compute the line width based on camera zoom though.

    --Eric
     
    Kaven-Co-Games likes this.
  8. RobertWebb

    RobertWebb

    Joined:
    Aug 3, 2015
    Posts:
    3
    Are there guidelines somewhere about when to create multiple lines in a single VectorLine vs when to create multiple VectorLines? I'm curious how big a performance difference it makes.

    For example, I'm writing a keyframer. It will show a vertical line for each keyframe. I could put all these in a single VectorLine, or create a separate VectorLine for each.

    Pros for single VectorLine:
    • Presumably more efficient (when not requiring a redraw), but by how much?
    Pros for multiple VectorLines:
    • When changing a single key, no need to redraw every key
    • May be more efficient while dragging one key, meaning it needs to redraw every frame while moving
    I couldn't find much discussion about this.
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It depends entirely on the effect of draw calls in Unity, which in turn depends on the graphics API used (OpenGL vs Vulkan for example). If you're talking about one VectorLine vs several VectorLines, I wouldn't worry about it. One vs hundreds could be more of an issue.

    --Eric
     
    RobertWebb likes this.
  10. flipwon

    flipwon

    Joined:
    Dec 29, 2016
    Posts:
    179
    This seems to be a VR only thing, but it seems the width of the line actually increases as it gets further away from the camera. I'm not sure if this is something you're aware of, any ideas?
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, in order for the width to remain a constant pixel value. There's no way around that for lines in 3D space.

    --Eric
     
  12. flipwon

    flipwon

    Joined:
    Dec 29, 2016
    Posts:
    179
    Damn, that's a shame. Really don't want to go back to built in line renderer but I don't think I have a choice :(

    Are there any plans on having an option to display them differently?
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, sorry.

    --Eric
     
  14. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    Hi @Eric5h5
    Great plug-in was using it for a while now. I am on Unity 2020 and Vectrosity 5.5
    I have started to see the problems with lines while orbiting perspective camera. I am using Draw3DAuto.

    Two questions:
    1. How to fix not straight lines ?
    2. Is there a way to keep line texture in place as currently it is sliding while orbiting the camera or updating points position?

    Thank you

    Here is my script and small animation:
    Code (CSharp):
    1. public class LineDrawer : MonoBehaviour
    2. {
    3.     [SerializeField] private LineConfigurationSO lineConfig;
    4.     [SerializeField] private PolygonRuntimeSetSO polygons;
    5.  
    6.     private VectorLine vectorLine;
    7.     private VectorLine vectorPoint;
    8.  
    9.     private void Start()
    10.     {
    11.         SetupLines();
    12.         SetupPoints();
    13.     }
    14.  
    15.     // Setup Vectro Lines
    16.     private void SetupLines()
    17.     {
    18.         // Setup Vector Line
    19.         vectorLine = new VectorLine(lineConfig.lineName, new List<Vector3>(), lineConfig.lineWidth, LineType.Continuous);
    20.         vectorLine.color = lineConfig.lineColor;
    21.         vectorLine.texture = lineConfig.lineTexture;
    22.         vectorLine.textureScale = 1.0f;
    23.     }
    24.  
    25.     // Setup Vectro Points
    26.     private void SetupPoints()
    27.     {
    28.         // Setup Vector Point
    29.         vectorPoint = new VectorLine(lineConfig.lineName + " point", new List<Vector3>(), lineConfig.pointWidth, LineType.Points);
    30.         vectorPoint.color = lineConfig.pointColor;
    31.         vectorPoint.texture = lineConfig.pointTexture;
    32.         vectorPoint.textureScale = 1.0f;
    33.     }
    34.  
    35.     // Draw graphics
    36.     public void DrawGraphics()
    37.     {
    38.         foreach (var polygon in polygons.Items)
    39.         {
    40.             DrawLines(polygon.Nodes);
    41.             DrawPoints(polygon.Nodes);
    42.         }
    43.     }
    44.  
    45.     // Draw lines
    46.     private void DrawLines(List<Node> nodes)
    47.     {
    48.         vectorLine.points3.Clear();
    49.         foreach(var node in nodes)
    50.         {
    51.             vectorLine.points3.Add(node.Position);
    52.             vectorLine.Draw3DAuto();
    53.         }
    54.         if (!lineConfig.isLineOpen && vectorLine.points3.Count > 2)
    55.         {
    56.             vectorLine.points3.Add(nodes[0].Position);
    57.             vectorLine.Draw3DAuto();
    58.         }
    59.     }
    60.  
    61.     // Draw points
    62.     private void DrawPoints(List<Node> nodes)
    63.     {
    64.         if (lineConfig.displayPoints)
    65.         {
    66.             vectorPoint.points3.Clear();
    67.             foreach (var node in nodes)
    68.             {
    69.                 vectorPoint.points3.Add(node.Position);
    70.             }
    71.             vectorPoint.Draw3DAuto();
    72.         }
    73.     }
    74. }
    LinesProblem.gif
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    1) That's usually the result of long, thin polygons, where the texture has issues being rendered properly by 3D hardware. If the lines are made from multiple shorter segments instead of long segments, that's much less visible.
    2) This is a lot harder since it's going against what Vectrosity is trying to do. That's an inevitable result given that it's screen-space oriented for drawing lines, even lines in 3D space. You could draw the shape when it's facing the camera, and then not update the line anymore after it's done (so you would not use Draw3DAuto). However the lines will naturally lose the "always maintain constant pixel width" feature.

    --Eric
     
    atbrief likes this.
  16. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    Thank you @Eric5h5
    Question 2 is ok for now.
    Question 1. Is there another way to deal with it?
    All my points are coming from ScriptableObject which I use in other places as well (for mesh generation)
    Do not want to add extra points
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not that I know of, sorry...it's caused by the way hardware renders textures on polygons, which isn't something that can be changed, only worked around.

    --Eric
     
    atbrief likes this.
  18. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    Hi @Eric5h5
    Jus to add to my question. The image with building it is what I want to get. Lines in 3d behind building.
    I tried Screen space lines, they do not have this problem, but obviously they are on top of the 3d objects.
    Maybe I can use screen space lines with some sort of mask ?
    Screenshot 2022-05-13 at 19.54.43.png Screenshot 2022-05-13 at 19.55.37.png
     
  19. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    If not, Is there a Utility tool on Vectrosity to add more points? method / function which takes start and end position ?
     
  20. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    If not. I think I can do it. Should be straight forward
     
  21. atbrief

    atbrief

    Joined:
    Dec 26, 2021
    Posts:
    15
    Also how can I get V5.6 ? Maybe it works better
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's the latest version on the store, but it's a minor update that works the same. I don't think there's any way to mask 2D lines like that since they're drawn on a canvas. Adding more points between two existing points is simple, yes; you can just use Lerp.

    --Eric
     
  23. OddViz

    OddViz

    Joined:
    Dec 17, 2019
    Posts:
    9
    Hi Eric,
    I'm running into an issue with Vectrosity using multiple cameras.

    I have one perspective camera, and one orthographic top-down camera, which i can see side-by-side. On both I wish to render a grid of lines. The problem is the lines always reference the same camera. So if I use SetCamera3D on the perspective camera, moving the perspective camera changes the line widths in the top view camera, and vice versa.

    I've tried setting the camera and then drawing the lines using OnPreRender, but this doesn't seem to work, the second SetCamera3D always overrides the first before drawing the lines.

    Is there a way to have Vectrosity reference two cameras simultaneously? Sorry if I'm missing something obvious.

    Thanks!
     
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're not missing anything, sorry; there isn't really a way to reference two cameras, short of rewriting the source to behave differently.

    --Eric
     
  25. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    65
    Hello,

    I just tried Unity 2022.1.1f and it seems I have problems with VectorLine objects.
    Can't seem to get "Vector Object 2D" to render anymore.
    In the "Scene View" the start & end point shows up as Editor UI but no lines are drawn.

    EDIT: I'm using the built-in render pipeline.

    Do you have an idea?

    Best regards,
    Christian
     
    Last edited: May 24, 2022
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, using Unity 2022.1.1, I can load any of the demo scenes and they function normally. You could try starting a new empty project to make sure it works there.

    --Eric
     
  27. Artpen

    Artpen

    Joined:
    Jan 24, 2015
    Posts:
    291
    Hi @Eric5h5

    What would be the most efficient way to updated List of points in VectroLine ?
    I have a Run time List of Vector3's and I am changing it over time. I am using it to create lines.
    Any advice?

    Also how to make a closed line ? connect last and first points, is there a function for it or should I make it.

    Thank you
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    VectorLines use List<Vector2> or List<Vector3>, so yes that's the most efficient way of updating points. To connect first and last points, just have the first point and last point be the same.

    --Eric
     
    Artpen likes this.
  29. CurryKitten

    CurryKitten

    Joined:
    Dec 22, 2016
    Posts:
    36
    I was just using Vectrosity to prototype some ideas and was using the MakeSpline function to draw a curvy line along some targets for the user to navigate.

    Very quickly making a script using some hardcoded vector3's in a list (and pretty much replicating what was in the Spline demo project) everything looked ok in my scene

    Screenshot 2022-06-29 at 14.27.09.jpg

    However, when I ran my full project - and the differences we have here is that there's a "base" set of common gameobjects that aren't destroyed and then scenes are loaded under the control of all this stuff - anyway, what appeared to happen is that the spline only drew itself to a certain number of points.

    Screenshot 2022-06-29 at 14.28.24.jpg

    The line sort of thins out after the point furthest from the camera. I thought this might be down to the camera - I do have my main player object tagged as MainCamera, but I also activated the temporary one I used in the scene to set it up and removed all the other cameras and still got the same result. So then I thought - ah, perhaps this is an issue with loading the scene and there's certain things that are in a weird state when we ask the script to run, so I deactivated the parent game object that was holding the script and then activated it after the main code had run up, and I got a different result again.

    Screenshot 2022-06-29 at 14.39.27.jpg

    This time almost the inverse of the previous one with the top area not being drawn, but the bottom area looking correct.. It seems all a bit curious, and I'm wondering if you can suggest any reason or circumstance this might happen so I can work around them. The code is as simple as it gets - hardcoded vector3 points (like I said, it's a quick prototype and a single draw)

    Code (CSharp):
    1. public List<Vector3> splinePoints = new List<Vector3>();
    2.  
    3.  
    4.     void Start()
    5.     {
    6.         Vector3 basePoint = new Vector3(1777.514f, -74.33327f, 1344.873f);
    7.         splinePoints.Add(basePoint + new Vector3(24.09583f, 121.0733f, -214.4733f));
    8.         splinePoints.Add(basePoint + new Vector3(24.09583f, 119.7933f, -56.87329f));
    9.         splinePoints.Add(basePoint + new Vector3(-42.21411f, 119.8233f, 73.12671f));
    10.         splinePoints.Add(basePoint + new Vector3(-164.9142f, 121.8333f, -36.97327f));
    11.         splinePoints.Add(basePoint + new Vector3(-185.8142f, 118.2333f, -188.5732f));
    12.         splinePoints.Add(basePoint + new Vector3(-171.7441f, 126.2133f, -376.7933f));
    13.  
    14.         var spline = new VectorLine("Spline", new List<Vector3>(100), 2.0f, LineType.Continuous);
    15.         spline.MakeSpline(splinePoints.ToArray(), 99, true);
    16.         spline.Draw3D();
    17.     }
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's definitely drawing the lines so they are oriented toward a different camera than the one you want. I'd suggest using SetCamera3D with the desired camera.

    --Eric
     
  31. CurryKitten

    CurryKitten

    Joined:
    Dec 22, 2016
    Posts:
    36
    I just gave that a go, but still getting the same result. The most confusing thing here is how the line just fades away, despite having the other points in the spline and loop being set to true. If I highlight the resulting spline from the updated code wth the SetCamera3D in place) you can see how both ends taper off.

    Screenshot 2022-06-29 at 23.40.18.jpg
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You do need to keep the line updated whenever the camera moves, in case you're not doing that. (Using Draw3DAuto or manually.)

    --Eric
     
  33. CurryKitten

    CurryKitten

    Joined:
    Dec 22, 2016
    Posts:
    36
    Aha - this was it, I was using Draw3D(). This is what happens when you speed read the docs and don't pay enough attention - I thought Draw3D was doing the automatic update per frame.... makes much more sense that Draw3DAuto() would do :) I guess what might have been happening with that incomplete line is it drew where the camera may have been during initialisation (so culling off what couldn't be seen) but when my camera moved as the game intialised we are left with an incomplete loop from the original draw?

    Anyway, moves me on forwards. Thanks for your help!
     
  34. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    862
    Hi Eric, I have a question about using drawTransform, it would be very useful since I want to make gizmo using vectrosity and I want it automatically update when i move the object.

    currently it's just two lines drawn in the base of the object (like axis) but when i use drawTransform lines are moved with some offset, they are not in the center any more, when not using drawTransform then lines are in the center without offset. Just to mention that root has some offset but i am using world position of the child (which local is zero but world isn't, it should account for the offset of the parent?)

    do you know what to look out for? or am i doings something wrong?

    code is pretty straightforward

    Code (CSharp):
    1.  
    2. // create two lines for axis
    3.             var x = new VectorLine("x",
    4.                 new List<Vector3> { selection.transform.position, selection.transform.position + Vector3.forward },
    5.                 null,
    6.                 4f, LineType.Continuous);
    7.  
    8.             x.drawTransform = selection.transform;
    9.             x.Draw();
    10.            
    11.             var z = new VectorLine("z",
    12.                 new List<Vector3> { selection.transform.position, selection.transform.position + selection.transform.right },
    13.                 null,
    14.                 4f, LineType.Continuous);
    15.            
    16.             z.drawTransform = selection.transform;
    17.             z.Draw()
    18.  
    19. ;
     
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I suspect the values of points in the lines are adding the offset, and should probably be zero in this case. That way the value is supplied by the position of the objects using drawTransform.

    --Eric
     
  36. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    862
    I am not sure what you mean,
    here is the hierarchy of the object

    root (has position and rotation -> I want this object as drawTransform
    - container (zero position and rotation)
    - mesh and collider (zero position and rotation)

    so when i use raycasting to select the object i get the one with mesh and collider and i use transform.position and that is world position and it has values of the root so lines are rendered at correct positions

    but when i set the line to use drawTransform of the root (which is moving) it adds the offset of something, what is correct way to do this?

    thank you!
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I mean that the points should not contain selection.transform.position and selection.transform.position + Vector3.forward, but rather Vector3.zero and Vector3.forward. You can't supply the position in the points and then add that same position using drawTransform; that's why you get an offset. You must pick one of the two: either use drawTransform or supply transform.position manually in the points list.

    --Eric
     
  38. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    187
    Pretty sure I already know the answer to this, but I'll ask: Is there any way (even if hacky) to have multiple textures on a single line? I.e. specifying a texture per point/segment like with colors?
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I think it might be possible to make a shader that uses different textures based on vertex colors, so using different line segment colors would result in different textures.

    --Eric
     
  40. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    187
    Thanks, I'll look into that!
     
  41. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    hello and thanks for vectrosity however it seems i cant make it run smoothly @Eric5h5
    here is my simple scenario MAKE BONES VISIBLE USING VECTROSITY in runtime
    please note my character moving every frame
    the script that i wrote is working but after a few seconds of entering play mode the FPS decrease to zero until engine crash!
    also lines doesn't move with the bones at all even using myline.transform! ,
    i know that's because calling draw on update but im very confused where to put that?
    i will appreciate for the right path!
     

    Attached Files:

    Last edited: Jul 12, 2022
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You keep adding points every frame forever, so yes it will crash. You have to not do that. In the future, please post code as code, not as a screenshot.

    --Eric
     
    Pourya-MDP likes this.
  43. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    hey , so sorry for the screen shot , dont know why i felt its a better way!
    can you please guid me on how to draw those bones!
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Just add the points once, not every frame.

    --Eric
     
  45. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hi Eric, hope you're well! I'm seeing an issue when trying to draw a thin-to-fat arrow with Vectrosity. Basically there's a treshold of fatness at the end where the end cap suddenly flips. Is this something silly I'm doing?



    Here's the code I'm using just to make sure I'm not doing anything wrong:

    Code (CSharp):
    1. public class ArrowTest : MonoBehaviour {
    2.     const int COUNT = 10;
    3.     readonly List<Vector3> _points =  new();
    4.     readonly List<float> _width =  new();
    5.  
    6.     public Texture2D _lineTexture;
    7.     public Texture2D _arrowHeadTexture;
    8.  
    9.     VectorLine _line;
    10.  
    11.     [SerializeField] float _startWidth = 5;
    12.     [SerializeField] float _endWidth = 40;
    13.  
    14.     void Awake() {
    15.         for (int i = 0; i < COUNT; i++) {
    16.             _points.Add(Vector3.zero);
    17.             if (i != 0) { _width.Add(0); }
    18.         }
    19.  
    20.         VectorLine.SetEndCap("Arrow", EndCap.Front, _lineTexture, _arrowHeadTexture);
    21.         _line = new VectorLine("Arrow Test", _points, 20, LineType.Continuous, Joins.Weld) {
    22.             endCap = "Arrow",
    23.             drawTransform = transform
    24.         };
    25.  
    26.         _line.MakeArc(transform.position, Vector3.back, 1.5f, 1.5f, 180, 270);
    27.     }
    28.  
    29.     void Update() {
    30.         float step = (_endWidth - _startWidth) / _width.Count;
    31.         for (int i = 0; i < _width.Count; i++) { _width[i] = _endWidth - step * i; }
    32.         _line.SetWidths(_width);
    33.  
    34.         _line.Draw();
    35.     }
    36. }
     
  46. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    I also can't seem to figure out how to make an arc travel in the opposite direction. I want to draw from 0 to 180, but I can't seem to make this happen counter-clockwise. (I'm using arrow end caps, so can't simply flip the values.)
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, I suspect that's to do with unwanted behavior when line segments are very small but also very thick, which basically causes the math to break. You'd need to have longer or thinner segments. For arcs, they're always defined using a clockwise order, so you can either define another end cap where the front and back textures are exchanged, or just use Vector3.forward for the up vector as opposed to Vector3.back.

    --Eric
     
    gumboots likes this.
  48. Benjamin_TYM

    Benjamin_TYM

    Joined:
    Jun 9, 2021
    Posts:
    11
    Hey, Is there a good way to avoid large allocations when creating VectorLines?

    I'm creating an array of vectorlines before combining their meshes but causing a lag due to garbage allocation / collection.

    Potentially could use a simple object pooling method but checking if there is an intended usage before going down that route.

    Many thanks!
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I wouldn't recommend using Vectrosity like that. If you have a number of lines, using a discrete line to draw them as a series of "separate" (but not really) lines is more efficient.

    --Eric
     
  50. Benjamin_TYM

    Benjamin_TYM

    Joined:
    Jun 9, 2021
    Posts:
    11
    Would that be essentially drawing multiple lines within a single new VectorLine? How would you add space between each "seperate" line? ie point A > B and C > D rather than A > B > C > D.