Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Vectrosity - Fast and Easy Line Drawing

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

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Sounds like it would be ideal for that. Whatever method you use for creating the chart, just plug those coordinates into a list and Vectrosity will draw it. You can use a "fake" texture-based glow effect, or do a full-screen image effect.

    --Eric
     
  2. ecoSamJoly

    ecoSamJoly

    Joined:
    Aug 6, 2018
    Posts:
    5
    Hi team, I have an error when build with the cloud:

    [Unity] Error: Could not load signature of Vectrosity.VectorLine:SetMask due to: Could not load file or assembly 'UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none>

    Any idea?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Try using the Vectrosity source rather than the DLL.

    --Eric
     
  4. ecoSamJoly

    ecoSamJoly

    Joined:
    Aug 6, 2018
    Posts:
    5
    Thanks Eric for your quick response! So I removed the DLL, and use the source. But it get this error:

    [Unity] Error: Could not load signature of LineDrawer:get_vectorLine (that is my class) due to: Could not load file or assembly 'Vectrosity, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:Vectrosity, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none>

    I am a bit confused...
    BTW, using Unity 2019.3
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Unfortunately I have no idea, sorry. I don't really know anything about cloud builds, I just remember Unity 2019 not liking the DLL due to UnityEngine.UI.

    --Eric
     
  6. ecoSamJoly

    ecoSamJoly

    Joined:
    Aug 6, 2018
    Posts:
    5
    Thanks again for your quick response!
    FYI, while It makes the debugging of a cloud builds failed log more confusing; it doesn't create the failure itself (I have successful build despite this error).
    I'll let you know if I have more information. Thanks again!!! : )
     
  7. ckannon

    ckannon

    Joined:
    Sep 10, 2013
    Posts:
    4
    Hey guys,

    Having the following problem. I adapted the SelectionBox from the demo from screen overlay to camera overlay and can't get it to position correctly.

    Code (CSharp):
    1.     void Awake () {
    2.         lineColors = new List<Color32>(new Color32[4]);
    3.         selectionLine = new VectorLine("CurrentActionSelection", new List<Vector2>(5), 3.0f, LineType.Continuous) {capLength = 1.5f};
    4.         selectionLine.SetCanvas(GameObject.Find("VectorCanvas").GetComponent<Canvas>());
    5.     }
    6.  
    7.     public void SelectTarget(GameObject target)
    8.     {
    9.         if (target == null) return;
    10.  
    11.         var posW = target.transform.position;
    12.         var node = MapGraph.GetNodeAt(posW);
    13.         var col = node.GetComponent<BoxCollider2D>();
    14.         var bmin = Camera.main.WorldToScreenPoint(col.bounds.min);
    15.         var bmax = Camera.main.WorldToScreenPoint(col.bounds.max);
    16.         var rect = new Rect(new Vector2(bmin.x, bmin.y), new Vector2(bmax.x - bmin.x, bmax.y - bmin.y));
    17.         selectionLine.MakeRect(rect, 0);
    18.         selectionLine.Draw();
    19.         StartCoroutine(CycleColor());
    20.     }
    21.  
    22.  
    My canvas is pre-created at 0,0,0. When draw gets triggered, the CurrentActionSelection gets added to my VectorCanvas... however the RectTransform position seems to be set to some wildly large numbers. If I modify it in the editor and make the values 0,0,0 - the shape appears correctly around the object I've selected.

    Tried a few things but can't seem to modify the RectTransform in code to achieve the same effect.

    Please help!

    Edit: nevermind, I figured it out. In the SetCanvas there is a boolean called WorldPositionStays that needed to be set to false.

    Thanks,
    Chris
     
    Last edited: Apr 15, 2020
  8. maciekfreak

    maciekfreak

    Joined:
    Sep 21, 2015
    Posts:
    22
    Hello

    I have strange behaviour only on Android device when using Vectrosity

    Code (CSharp):
    1. line = new VectorLine("lineDiscrete", points, 6f, LineType.Discrete);
    2. line.Draw3D();
    It is visible on video below:


    What could be the reason for this problem and how can you deal with it?
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Usually a problem on only one specific platform means a Unity bug regarding that platform, or possibly some hardware limitation. As I'm not particularly familiar with Android and haven't seen anything like that before, I'm afraid I can't even guess what the issue could be.

    --Eric
     
  10. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    61
    Hi Eric5h5
    Im using Vectrosity to Draw UI 2D lines, i found an issues :
    Generated lines wwillbe auto created in new Canvas so they will supperposed to my main Canvas, lines are shown on UI windows i want them under UI items.
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You can use SetCanvas to assign lines to a specific canvas.

    --Eric
     
  12. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    61
    Thanks i will try it.
     
  13. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    77
    I had a chance to finally pick up Vectrocity and so far i'm finding a few things quite hard to work with.

    1. In order to add a VectorObject2D it must be an immediate child of it's own canvas. For my use case I was hoping I could add the VectorObject2D line as I normally would with any other canvas component.
    2. When editing point positions in editor it looks like i can't drag the float value of x or y as I normally would with any other float field in Unity. Currently it looks as if i must enter values in manually which is pretty tough.
    3. It doesn't look like undo is not supported out of the box when making changes in the editor to VectorObject2D.

    I have no doubt on the code side this thing works really well, but right now it seems like i'm having a lot of front facing editor issues.

    Btw i'm currently on Unity 2018.4.17f1 and i'm using Odin Inspector (this might be causing some conflicts leading to the issues).

    Lastly I would say the first issue is bigger in terms of wants for me then the second 2.

    Just wanted to throw my feedback up on the forum as I really want to love this asset as I've heard great things.
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Thank you for the feedback. Vectrosity is primarily intended as a coding asset; the editor UI functionality didn't exist at all until version 5, so the feature focus does tend to reflect that.

    --Eric
     
  15. UnityGISTech

    UnityGISTech

    Joined:
    May 6, 2015
    Posts:
    61
    Worked well thanks
     
  16. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    80
    Hi Eric!

    I am drawing weapon arcs for turrets using 3d lines 1 arc and 2 lines for the sides, just like a pizza slice. Is there an inbuilt way to shade the inside of the "slice"?

    Cheers!
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Hi, not sure I'm quite following what you're doing, but maybe you could use some kind of custom two-sided shader with a custom material (using VectorLine.material). Unity doesn't have any built-in two-sided shaders as far as I know.

    --Eric
     
  18. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    69
    Hi Eric,

    this is probably a dumb question but I am having issues with understanding the principles of how Vectrosity works.

    In 2D the lines are drawn as an overlay canvas, which means screen space. If I wanted to use the asset to draw borders on 2D sprites, do I understand correctly that I'd need to convert the world coords of the objects to screen space every update step?

    Is using Vectrosity for anything that relies on the camera (zooming, panning) is a bad use case and going for custom shaders is the solution?

    Thanks!
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    You can use 3D coordinates. VectorLine.Draw() uses either Vector3 (world space) or Vector2 (screen space) coords.

    --Eric
     
  20. nikix22

    nikix22

    Joined:
    Jan 16, 2015
    Posts:
    24
    Hi :) Thanks for this asset!
    Just one question about Curve demo, this with Bezier moving lines.
    https://starscenesoftware.com/vectrositydemo5.html
    When I open in unity and start it just display image, but there is no end control points?
    Can't get it to work.
    Also, when move control points manually, directly on object from hierarchy, nothing is happening.
    Can I get it to work interactively?
    I am using Unity 5.6.7f1

    Greets!

    UPDATE: I got it to work!
    Just needs to do following:
    1. Create a new scene.
    2. Attach a Physics 2D Raycaster to camera.
    3. Add EventSystem into Scene (GameObject -> UI -> EventSystem)
    4. Add then content for Curve drawing.
     
    Last edited: Jun 9, 2020
  21. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    38
    Hi Eric, have you done any testing with 2020.1.0f1 yet? Came back to an older project and getting a bunch of errors (recursive deserialization, missing references) but they are different every time I open Unity.

    I'm probably going to rebuild the whole thing but figured I'd check with you first.

    Thanks!
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    I did some brief testing and didn't encounter any problems like that.

    --Eric
     
  23. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    110
    I've found that moving a project to 2020 breaks any VectorObject2Ds. I can add new VectorLines without any immediate problems, but bringing one in from Unity 2018 causes it to error and kill the component.
     
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Hmm, seems to be something in Unity's project upgrade process. Unfortunately I haven't found anything I can do about it.

    --Eric
     
  25. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    310
    Can I use Vectrosity with an orthographic camera, which is drawing to a render texture? Screen space Camera seems like the mode i want but I get msgs that it is not supported.. how else should i get vectrosity to show up on a texture in the scene?
     
  26. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    310
    I am seeing this a lot: A Canvas named "VectorCanvas" with a render mode of ScreenSpaceOverlay is being used while VR is also enabled. This Canvas will continue to incur a rendering cost, but will not be visible while in VR. Is this intentional?

    but it does not occur in an older project. What might be causing this?
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    A canvas is created if you use 2D lines (whether made with Vector2 or Vector3), since that's how they're drawn. A canvas is not created if you use Draw3D. You can use an orthographic camera; you don't need to use ScreenSpaceCamera for that. But if you still want to, not supported doesn't mean it won't work, just that it wasn't designed for that and the behavior may have side effects. If it works the way you want, you're free to use it.

    --Eric
     
unityunity