Search Unity

Vectrosity - Fast and Easy Line Drawing

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

  1. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    45
    Thanks for the detailed and quick reply Eric!
     
  2. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    @Eric5h5

    Is all of the Vectrosity source code enclosed in a namespace? I was running into a few issues with the DLL and just started looking at the source code version.

    I am using Vectrosity is 5.3 (latest available) and Unity 5.4.1f1 (PRO) (Windows 64-bit). Running on Windows 8.1 PRO (64-bit) operating system.
     
    Last edited: Oct 2, 2016
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    The VisibilityControl scripts weren't. (I've changed that now.)

    --Eric
     
  4. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    I see these files do not have namespaces ... Plugins\Vectrosity\Scripts

    BrightnessControl.cs
    RefInt.cs
    VisibilityControl.cs
    VisibilityControlAlways.cs
    VisibilityControlStatic.cs

    And these in the editor section ... Plugins\Vectrosity\Editor

    LineMaker.cs
    UIVector2D.cs
    VectorObject2DEditor.cs
     
    Last edited: Oct 2, 2016
  5. ppix

    ppix

    Joined:
    Sep 6, 2016
    Posts:
    5
    @Eric5h5
    In VectorObject3D.cs, the semantics of setting a custom material via SetVectorLine or via SetMaterial are quite different.
    Which I believe means that setting a custom material on a Vectorline before or after the first draw behaves quite differently.
    In particular, SetVectorLine copies the material, whereas SetMaterial does not. Also, SetMaterial sets the useCustomMaterial flag, whereas SetVectorline does not.
    Is there a reason for this?
    The fact that the material gets copied caused me lots of head scratching yesterday (before I realized this was happening).
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    There were some requests for changes in the way that materials were handled, but evidently I wasn't 100% consistent with the way I implemented them. So I fixed that for the next version.

    (In any case, the explanation for using new materials is because in the case where you don't use VectorLine.material, the default material is used, but this needs to be unique so that using different textures doesn't change the texture on all the lines. As I mentioned I've now fixed this, so that using a custom material doesn't create a new material at all.)

    --Eric
     
  7. ppix

    ppix

    Joined:
    Sep 6, 2016
    Posts:
    5
    Thanks for the explanation and the upcoming fix. I appreciate it.

    I have another (unrelated) question:
    I attached one 3D line to one of the controllers of the HTC Vive (using the SteamVR prefab) by setting the drawTransform to the controller object's transform.
    The issue I am having is that the line lags behind the movement of the controller mesh. If I attach other geometry to the controller (via transform.SetParent) it moves in perfect sync with the controller.
    I already tried putting the line.Draw3D() call into LateUpdate(), instead of using Draw3DAuto(), but unfortunately this did not help. Any idea how I might be able to eliminate this lag?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Draw3DAuto already uses LateUpdate; if an object linked to a line with drawTransform is moved in Update, then the line is drawn later that frame. The only any way I know of to have any lag is if the linked object is moved in LateUpdate rather than Update.

    --Eric
     
  9. ppix

    ppix

    Joined:
    Sep 6, 2016
    Posts:
    5
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    3D lines (Draw3D/Draw3DAuto) don't use a canvas, but are meshes drawn in the scene.

    --Eric
     
  11. ppix

    ppix

    Joined:
    Sep 6, 2016
    Posts:
    5
    Thank you, yes, I understand. I was saying that this lag issue with Vive controllers also affects canvas elements. The described workaround fixes the issue for canvas, but does not fix it for the 3D line.
    For now I'll just use a cylinder or stretched cube instead of a 3D line.
     
  12. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    Can colliders for 2D lines be generated in world space instead of camera overlay space? Or this needs to be done manually?
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Colliders are only generated in world space; see the RandomHills demo.

    --Eric
     
  14. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    In your hills demo line is drawn in camera overlay space and colliders are created in world space relative to camera. In what I'm trying to do, camera moves, so that way is not applicable (and that's a more common case than collider whose parent is camera).
    What I meant is if it possible to have line on a world space canvas and colliders be generated exactly where it is simply by omitting Z coordinate or do I need to do that manually, well, actually, I already did that manually since my last post, but that's not a good thing overall.
    Options I'm missing so far:
    1. Building custom 3D lines in editor. For sketching in editor still have to use Unity LineRenderer.
    2. What I described above, world coordinate lines collider building which doesn't rely on camera.
    3. Custom forced rotation of 3D lines. If it would've been possible to make them always face up and then generate cube colliders, that would've been a 3D road made in a minute. Luckily, my current project can live fine with 2D roads.
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    World space canvas is not supported, but instead you can simply use Vector3 world coordinates for the line and the collider works fine when moving the camera. (Just call Draw on the line when the camera moves.)

    --Eric
     
  16. dan-hilton

    dan-hilton

    Joined:
    Oct 13, 2016
    Posts:
    3
    I have been using Vectrosity for some time and have been very happy with it. However at some point the lines I have been drawing started to look intermittent (dotted). They used to look correct but now have this problem. THey are 3d lines rendered with Draw3D() method. I could try just increaing the width but ideally i would like them to be only one pixel at the most in screen space (although they are 3d lines). Any ideas what might have changed to cause them to become intermittent lines?

    Thanks
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Are you using the correct camera with SetCamera3D? And are calling Draw3D when moving the camera, or using Draw3DAuto?

    --Eric
     
  18. dan-hilton

    dan-hilton

    Joined:
    Oct 13, 2016
    Posts:
    3
    Thanks for the quick response. I am not calling SetCamera3D at all I dont think. Is that a fairly new call? (I wrote most of this like 2 years ago) Anyways I'll try that thanks for the help
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    It's been around for a long time. It's not necessary if you have a single camera tagged "Main Camera", but if you have more than one, you need it to set up the camera that lines are oriented to.

    --Eric
     
  20. dan-hilton

    dan-hilton

    Joined:
    Oct 13, 2016
    Posts:
    3
    Still getting the same behavior... I am trying to draw essentially a 1 pixel line based on a 3d line path. By thickening the line to 1.0 it is no longer an intermittent line...but it really does no look as smooth as it used to...almost like the is no AA at all when the lines are rendered. I can live with what i'm getting now but curious if there are some smoothing seetings i might look into
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Yes, using fewer than 1 pixels for the width doesn't generally work well. AA depends on what you're using in Unity; Vectrosity lines are just a mesh.

    --Eric
     
  22. CatDevPete

    CatDevPete

    Joined:
    Aug 30, 2012
    Posts:
    17
    I'm trying to draw a great number of lines inn 3D space. For performance reasons, I'm avoiding redrawing them constantly. However, when I manually redraw the lines, the ones outside the camera frustum are not rendered until I call the draw3d method. Would it be possible to render 3D lines outside of the camera's frustum without having to redraw?
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    I'm not quite following, since you mention manually redrawing, but in your post this sounds like it's something different from Draw3D. How are you manually redrawing?

    --Eric
     
  24. CatDevPete

    CatDevPete

    Joined:
    Aug 30, 2012
    Posts:
    17
    Sorry, I meant using Draw3D to update the lines.
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    I don't really understand what you're attempting, sorry. There aren't any methods for updating lines aside from Draw and Draw3D, though.

    --Eric
     
  26. CatDevPete

    CatDevPete

    Joined:
    Aug 30, 2012
    Posts:
    17
    Yeah, I had a feeling. Simply put. I'm making a VR application where large amounts of lines are rendered all around the person in 3D space. In front of them, behind them, to their right, etc.
    Lines within the camera's view are properly rendered when I call Draw3D, but all the other lines outside of the view do not get drawn when I turn around, until I call Draw3D again.
    If I use Draw3DAuto, the framerate drops to about 11fps average. Calling Draw3D when the player turns is better, but still results in stutters. Although I can try to position the player away so they can see all the lines from the start, I was hoping there was an easy way to draw all the lines out even if they weren't in the camera's frustum.
     
  27. Pixeye

    Pixeye

    Joined:
    Jul 2, 2011
    Posts:
    193
    Hi @Eric5h5 ! I'm trying to draw turret's sight. I use one VectorLine with 2 arcs and 2 lines. It works fine but I would like to "smooth" corners. I've read vectrosity manual about joins but couldn't get it all working as wanted. Could you please help me to fix that?

    The code :

    Code (CSharp):
    1.  void CreateSight()
    2.     {
    3.  
    4.          SightLine = new VectorLine(gameObject.name + "_sight", new Vector3[smooth*4].ToList(), 4f, LineType.Discrete, Joins.Weld);
    5.         float StartAngle = 90 - (MaxAngle * 0.5f);
    6.         float EndAngle = 90 +  (MaxAngle * 0.5f);
    7.  
    8.         Vector3 LeftLowPoint = new Vector3(Radius * 0.15f * Mathf.Cos(StartAngle / Mathf.Rad2Deg), Radius * 0.15f * Mathf.Sin(StartAngle / Mathf.Rad2Deg), 0);
    9.         Vector3 RightLowPoint = new Vector3(Radius * 0.15f * Mathf.Cos(EndAngle / Mathf.Rad2Deg), Radius * 0.15f * Mathf.Sin(EndAngle / Mathf.Rad2Deg), 0);
    10.  
    11.         Vector3 LeftTopPoint = new Vector3(Radius * Mathf.Cos(StartAngle / Mathf.Rad2Deg), Radius * Mathf.Sin(StartAngle / Mathf.Rad2Deg), 0);
    12.         Vector3 RightTopPoint = new Vector3(Radius * Mathf.Cos(EndAngle / Mathf.Rad2Deg), Radius * Mathf.Sin(EndAngle / Mathf.Rad2Deg), 0);
    13.  
    14.      
    15.  
    16.           SightLine.points3.Add(new Vector3(LeftLowPoint.x, LeftLowPoint.y, 0));
    17.           SightLine.points3.Add(new Vector3(LeftTopPoint.x, LeftTopPoint.y, 0));
    18.           SightLine.points3.Add(new Vector3(RightLowPoint.x, RightLowPoint.y, 0));
    19.           SightLine.points3.Add(new Vector3(RightTopPoint.x, RightTopPoint.y, 0));
    20.  
    21.  
    22.           SightLine.MakeArc(center.position, Radius * 0.15f, Radius * 0.15f, 90 + StartAngle, 90 + EndAngle, smooth, 0);
    23.  
    24.           SightLine.MakeArc(center.position, Radius, Radius , 90 + StartAngle, 90 + EndAngle, smooth, smooth * 2);
    25.  
    26.           SightLine.Draw3D();
    27.    
    28.  
    29.     }
     
  28. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    @pixeye
    Nice short code. :cool:

    Mine (for a 2d stuff)
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using Vectrosity;
    5. using System.Collections.Generic;
    6.  
    7. public class HudMakeRadar : MonoBehaviour
    8. {
    9.    public Texture lineTexture;
    10.    public Color lineColor = Color.white;
    11.    public int Rayon  = 100;
    12.    private int Rayon2;
    13.    public int Distance = 150;
    14.    [Range(10.0f,270.0f)] public float angle  = 90.0f;
    15.    [Range(20,30)]  public int segments =  30;
    16.    private int segments2;
    17.  
    18.    public int x = 100;
    19.    public int y = 100;
    20.    public float EpaisseurLigne = 4.0f;
    21.    public float pointRotation  = 0.0f;
    22.  
    23.    private VectorLine HudRad1;
    24.    private VectorLine HudRad2;
    25.    private VectorLine HudLine;
    26.    
    27.    // Use this for initialization
    28.    void Start ()
    29.    {
    30.      segments2 = segments * 2; // plus de segments au 2 eme Arc de cercle !!!
    31.      Rayon2 = Rayon + Distance;
    32.      
    33.      var HudPoint1 = new List<Vector2>(segments  + 1);
    34.      var HudPoint2 = new List<Vector2>(segments2 + 1);
    35.  
    36.      HudRad1 = new VectorLine("HUD_RAD1", HudPoint1, lineTexture, EpaisseurLigne, LineType.Continuous, Joins.None);
    37.      //HudRad1.capLength = 1.0f;
    38.      HudRad1.color = new Color(0.0f, 0.75f, 1.0f);
    39.      //HudRad1.color = lineColor;
    40.      HudRad1.MakeArc(new Vector2(x,y), Rayon, Rayon, 0.0f, angle, segments);
    41.      HudRad1.Draw();
    42.      
    43.      HudRad2 = new VectorLine("HUD_RAD2", HudPoint2, lineTexture, EpaisseurLigne, LineType.Continuous, Joins.None);
    44.      //HudRad2.capLength = 1.0f;
    45.      HudRad2.color = new Color(0.0f, 0.75f, 1.0f);
    46.      //HudRad2.color = lineColor;
    47.      HudRad2.MakeArc(new Vector2(x,y), Rayon2, Rayon2, 0.0f, angle, segments2);
    48.      HudRad2.Draw();
    49.  
    50.      var HudPointL = new List<Vector2>();
    51.      HudPointL.Add (HudRad1.points2[0]);
    52.      HudPointL.Add (HudRad2.points2[0]);
    53.      HudPointL.Add (HudRad1.points2[segments]);
    54.      HudPointL.Add (HudRad2.points2[segments2]);
    55.  
    56.      HudLine = new VectorLine("HUD_RAD_L", HudPointL, lineTexture, EpaisseurLigne, LineType.Discrete, Joins.Weld);
    57.      //HudLine.capLength = 1.0f;
    58.      HudLine.color = new Color(0.0f, 0.75f, 1.0f);
    59.      //HudLine.color = lineColor;
    60.      HudLine.Draw();
    61.    }
    62.    
    63. }
    64.  
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    It would be better to use a continuous line instead of discrete, and make sure that there are no points that have the same coordinates (except the first and last).

    --Eric
     
  30. Pixeye

    Pixeye

    Joined:
    Jul 2, 2011
    Posts:
    193
    I tried but very confused with order of drawing. All my attempts of making it in one vectorline with continuous line failed.



    @ZJP
    Thanks : ) Btw, at first I did something similar to your code, but I want to make it per one vectorline : )
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    The welding can't work unless the line is drawn continuously around the shape, either clockwise or counter-clockwise (regardless of using LineType.Discrete or Continuous), with no repeated points. You might have to make a custom function rather than using MakeArc.

    --Eric
     
  32. ok_remi_ok

    ok_remi_ok

    Joined:
    Sep 16, 2014
    Posts:
    7
    Hello !
    I'm having some kind of glitch with Vectrosity.
    It occurs only on Windows build (the project is made on a Mac).
    I am recklessly using the latest Beta of 5.5 (b8) and this behavior is the same for all 5.5.x currently out.
    I have those lines which I set up on Start() with DrawAuto3D().
    Even when I don't move the points at runtime, at random frames, it seems like what I assume to be the last vertice of the generated mesh doesn't draw, or is set to 0,0,0. It really happens at random frames but quite often, even when there is no movement.
    It doesn't happen when the lines are not 3D though.

    It really flickers randomly. It happens only on builds, not on the Editor.
    Even though I am using a beta version, would you have a guess on why Draw3DAuto + Windows is breaking the line ? I thought it would be framerate related, but the script is the same on Windows & Mac.....
     
    Last edited: Oct 24, 2016
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    As far as I can see that would have to be a bug in Unity given the conditions you describe...if there is no movement, the output from Vectrosity is 100% identical every frame, and you mention it working fine in the editor and other platforms. Actually it's more likely to be a specific graphics card driver bug that Unity might need to work around (if this was common in Windows builds I would have heard about it before), but in any case it doesn't appear that there's much I could do, so a bug report would be in order (you can include Vectrosity when submitting bug reports). If you have any driver updates available, I'd suggest doing that first. Or as a workaround, you could try adding an extra segment to the end of the line, using SetColor to make the color of that segment transparent, so that any flickering wouldn't be visible.

    --Eric
     
  34. shoo

    shoo

    Joined:
    Nov 19, 2012
    Posts:
    60
    How could I get Texture2d or Color32[]? I need to draw lines on texture, not on the whole screen.
     
    Last edited: Oct 31, 2016
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Vectrosity can't draw lines in textures per se, but you could use a rendertexture. If using a canvas, it would have to be set to screen space camera, rather than overlay, in order to show up in a rendertexture.

    --Eric
     
  36. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    453
    Hi Eric,

    I submitted a support request through your website just before the weekend. Did you happen to receive it?

    Thanks.
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Hi, I got a couple of requests, which I replied to. What was it concerning?

    --Eric
     
  38. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    453
    I haven't received a reply, so I'll assume it didn't go through. It's regarding a console error using MakeCircle when adding enough entries to the points3 list on the same frame before calling VectorLine.MakeCircle:

    VectorLine.MakeEllipse: The length of the array for discrete lines needs to be at least twice the number of segments for "test"

    I couldn't figure out why I was getting that error in my project when there seemed to be the correct amount of points and the circle (or triangle, because there's 3 segments using 6 points) was rendering correctly, so I made a simple test to see if I could narrow down the problem.

    If you create a new scene and attach the following script to the camera, you will see that the Debug.Log shows 6 points in the list right before calling MakeCircle, which should be enough, but the console shows the error and the triangle is not rendered on the first frame. However, for every subsequent frame, there is no error. If I add 5 points instead, the error correctly comes up every frame. If I put more than enough points, 7 for example, the same error exists only for the first frame.

    Code (CSharp):
    1. public class TestScript : MonoBehaviour
    2. {
    3.     private VectorLine line;
    4.  
    5.     void Awake()
    6.     {
    7.         List<Vector3> points = new List<Vector3>();
    8.  
    9.         line = new VectorLine("test", points, 1f, LineType.Discrete, Joins.None);
    10.     }
    11.  
    12.  
    13.     void Update()
    14.     {
    15.         while (line.points3.Count != 6)
    16.         {
    17.             line.points3.Add(Vector3.zero);
    18.         }
    19.  
    20.         Debug.Log(line.points3.Count);
    21.         line.MakeCircle(Vector3.zero, Vector3.up, 5f, 3, 0f, 0);
    22.         line.Draw3D();
    23.     }
    24. }

    Does MakeCircle need one frame to register the points3 list somehow?

    In my project, I'm dynamically adding/removing points and calling MakeCircle on the same frame after altering the size of the points list. It's displaying correctly, but I still get that same error even though there are enough points before calling MakeCircle.

    Thanks.
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    Good catch; I changed how points were accessed a while ago but didn't appropriately update some things in the VectorUtilities script. I've fixed this for the next version. (If you want to do it now, change from dll to source if necessary, and in VectorUtilities, replace any instance of m_pointsCount with pointsCount, except for inside MakeWireframe.)

    --Eric
     
    Korindian likes this.
  40. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    453
    Hi Eric, I'm also noticing that after parenting a line to a transform for organizational purposes using myLine.rectTransform.SetParent(someTransform) before calling Draw3D, once I call Draw3D the line gets unparented.

    Is this intended? If I call Draw3D before parenting, it stays parented.
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    It's not really recommended to parent Vectrosity objects manually, since that tends to interfere with the drawing routines if you're not careful. In any case the line doesn't exist yet in the scene when you call new VectorLine, since how it's drawn depends on whether you use Draw or Draw3D afterward (specifically Draw requires it to be a child of a canvas).

    --Eric
     
    Korindian likes this.
  42. davedev

    davedev

    Joined:
    Jan 12, 2009
    Posts:
    62
    How would I save an image of Vectrosity 2D drawn lines to disk as PNG? I've searched on this and didn't find anything.
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    You could use a rendertexture. If using a canvas, it would have to be set to screen space camera, rather than overlay, in order to show up in a rendertexture.

    --Eric
     
  44. davedev

    davedev

    Joined:
    Jan 12, 2009
    Posts:
    62
    Thanks. I've tried using a render texture now but the drawn lines no longer appear. The mask I am using appears over my scene but when I draw lines on it they don't appear in the game view. DrawLine objects appear as a child of my Canvas>Mask Image, but there's an error message, "DrawLine: Only canvases using Screen Space Overlay are supported."

    The render camera for the Canvas is set to Main Camera and Render Mode = Screen Space - Camera.

    This just in. If I disable the mask the drawn lines do display, but don't show up when I try to capture them in a render texture/screenshot with some code like this:

    Camera camera = gameObject.GetComponent<Camera>();
    RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
    camera.targetTexture = rt;
    Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
    camera.Render();
     
    Last edited: Nov 6, 2016
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    That's not an error message, it's just the scene view line editing info box. In this case editing lines in the scene view isn't supported because the scene view coords get confused with screen space camera, but it still displays fine. (Also you can still manually edit the line points in the list in the inspector, or temporarily switch back to screen space overlay if you want to edit in the scene view.)

    Anyway, the reason for not showing up in the game view would be if you're using VectorLine.SetMask in code, since it uses SetParent with worldPositionStays = true, which doesn't really work for screen space camera. So I've added an option to specify worldPositionStays for the next version (set it to false when using screen space camera). If you want to add that now, switch to source rather than dll if necessary, remove the SetMask functions from the VectorLine script, and replace them with these:

    Code (csharp):
    1.     public void SetMask (GameObject maskObject) {
    2.         SetMask (maskObject, true);
    3.     }
    4.  
    5.     public void SetMask (GameObject maskObject, bool worldPositionStays) {
    6.         var mask = maskObject.GetComponent<Mask>();
    7.         if (mask == null) {
    8.             Debug.LogError ("VectorLine.SetMask: mask object must have a Mask component");
    9.             return;
    10.         }
    11.         SetMask (mask, worldPositionStays);
    12.     }
    13.  
    14.     public void SetMask (Mask mask) {
    15.         SetMask (mask, true);
    16.     }
    17.  
    18.     public void SetMask (Mask mask, bool worldPositionStays) {
    19.         if (m_canvasState == CanvasState.OffCanvas) {
    20.             Debug.LogError ("VectorLine.SetMask only works with lines made with Draw, not Draw3D.");
    21.             return;
    22.         }
    23.         if (mask == null) {
    24.             Debug.LogError ("VectorLine.SetMask: mask must not be null");
    25.             return;
    26.         }
    27.         m_go.transform.SetParent (mask.transform, worldPositionStays);
    28.     }
    Here's a basic line being masked by a circle with SetMask with a screen space camera canvas:

    Screen Shot 2016-11-05 at 10.10.59 PM.png

    --Eric
     
  46. saha96

    saha96

    Joined:
    Feb 28, 2016
    Posts:
    1
    Is it possible for the line drawn using Vectrosity to act under gravity similar to a rigidbody? I have a VectorLine with a collider which I want to "fall" under gravity similar to say a circle with a rigidbody2D attached to it? Is that possible? I am guessing I have to attach a rigidbody2D to the separate line objects?




    For example, here the spheres act fine as thought the whole line is a collider which is fine, but in addition to that, I want that line to fall under gravity as well. Is that possible?
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    You can try line.rectTransform.gameObject.AddComponent(Rigidbody2D), though I'm not sure if 2D physics handles that kind of collider as a rigidbody very well.

    --Eric
     
  48. moire76

    moire76

    Joined:
    Jan 20, 2016
    Posts:
    6
    Hi Eric,
    I'm new to vectrosity and having an issue I couldn't solve so far. Sorry if its already discussed, I couldn't find an answer by searching the forums either.
    I created all edges for a cube and a triangle inside the cube, all from script. Now when I rotate the cube the lines not always covering each other properly.
    I made a video for better representation:

    Thanks very much for any help in advance!
    Cheers,
    Moire76
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,175
    It appears there's an orange line segment with the same coordinates as a red line segment, so there's no way to determine which one should be drawn on top. I'd suggest moving the orange segment in slightly so it's not exactly coplanar. Although you'd need to make sure you're using a shader with zwrite on for that to work.

    --Eric
     
  50. moire76

    moire76

    Joined:
    Jan 20, 2016
    Posts:
    6
    Dear Eric,
    Thank you for your fast answer!
    I know this for that back edge, but my problem is rather the long side of the inner yellow triangle.
    I created another vid with thicker lines for better vibility. When rotating, the cube edges are both either in front or behind of that longer yellow triangle side, even when one should be in front and other should be behind. I'm sure it will be clear by watching this new vid!
    Thank you very much!
    Moire
     
    Last edited: Nov 9, 2016