Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    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,307
    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,307
    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,307
    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:
    23
    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,307
    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:
    121
    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,307
    You can use SetCanvas to assign lines to a specific canvas.

    --Eric
     
  12. UnityGISTech

    UnityGISTech

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

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    107
    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,307
    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:
    121
    Worked well thanks
     
  16. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    83
    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,307
    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:
    70
    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,307
    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:
    40
    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,307
    I did some brief testing and didn't encounter any problems like that.

    --Eric
     
  23. PanicEnsues

    PanicEnsues

    Joined:
    Jul 17, 2014
    Posts:
    134
    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,307
    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:
    361
    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:
    361
    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,307
    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
     
  28. 0898_TGS

    0898_TGS

    Joined:
    Oct 23, 2016
    Posts:
    3
    Hello, there is a strange phenomenon that needs to be consulted.
    The line starts to display normally, If the "Myline.rectTransform.anchoredPosition.y < N" of a line segment changes beyond a certain value, Line segments are not displayed.
    111.png

    continue ‘ Myline.rectTransform.anchoredPosition += new Vector2(0, -50)’. The line segment is not displayed
    222.png
    Is there no setting for where I am?
     

    Attached Files:

  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    Hi, I'd recommend not manually moving rectTransforms for lines. Stick to supplying points for the points2 array and use VectorLine.drawTransform if you want to "attach" a VectorLine to another transform.

    --Eric
     
  30. 0898_TGS

    0898_TGS

    Joined:
    Oct 23, 2016
    Posts:
    3
    OK, thank you for your advice
     
  31. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    140
    Hi,

    I just wanted to comment on a behavior of the textureScale property when used with Discrete lines that has been bugging me a lot.

    It seems like the texture is tiled over the entirety of all the line segments, rather than each individual segment. For example, this means that if segment #1 increases in length, causing the texture's tiling to change, all subsequent segments after will have their textures affected as well. This also occurs for anything that would cause the line to be redrawn, such as camera movement for 3D lines. It creates a very apparent scrolling effect when using dotted line textures.

    I love using a single Discrete line for drawing many disconnected line segments because of the performance vs using many individual lines, but this behavior prevents me from being fully satisfied with it.
     
    Last edited: Oct 14, 2020
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    For that case you'd probably be better off using a material for the line and setting the tiling parameter in the material.

    --Eric
     
  33. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    140
    As I look more into it there's just general issues with dotted 3D lines that use textureScale.

    Like I mentioned, camera movement causes a lot of scrolling and flickering, not portrayed very well in this screen capture but I think it's still apparent:
    https://i.gyazo.com/d2a4ab60aa06786ed0b74c1c9d5abef7.mp4

    Also some viewing angles do not work well:
    https://i.gyazo.com/d4c05153746f6f87f5fb86fde43cd6e1.png

    Using the material's tiling as you advised is a serviceable backup, but this is just 1 of 2 issues that I think keep Vectrosity from being 100% perfect. (The second is being able to set a line's width in world space, like the LineRenderer, but that a whole different thing)
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    The design of textureScale is intended to keep textures consistent in screen space, so it will never work well in world space, or at least not for the kind of use case you're illustrating. Also the intention is to keep lines a consistent pixel width regardless of camera distance, which is indeed not like the LineRenderer, specifically by design (actually it's the entire reason I made Vectrosity in the first place).

    --Eric
     
  35. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    121
    Hello and so much thanks for this great tool
    One question btw
    How to create a cellgrid matrix using vectorsity?similliar to this one on the 4:17?

    https://m.youtube.com/watch?v=b0Mk9lHz6co

    Now you may ask that this is a reday to go tutorial and why i dont use it?im using it and even i modified it a bit to my need
    This tutorial uses Gl.line to draw that matrix in loops
    I already getting 40fps on galaxy a10s with that
    Now i have another question will vectorsity give me more fps?if yes can you point me how can i recreate that effect using your tool?
    And the last question i read a bit documantation and saw for creating a for example wireframe for a cube theres hundreds of points in the script,do we have to put all thoese points manually to make a simple wireframe for our 3d model??
    Thanks in advance

    Ps:just wow i really surpeised how fast and easy is using this asset it took me almost 3 hours of struglling but finally i made the matrix by simply replacing the gl.vertex to vectorline.points and then draw
    But now i have a wiered problem which is the lines are getting some sort of culling or fading even in small distances like the image below
    How can i solve it?
    20201102_200146.jpg
     
    Last edited: Nov 2, 2020
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    That would be easy enough...probably just modify the Grid3D demo script, so instead of one grid on a 2D plane, you'd make a loop so it makes a series of horizontal grids on the Y axis, then a series of connecting vertical lines on the Z axis. As for performance, there's no good way to answer that aside from "it depends"; the more points there are, the slower it would be. Not sure what you mean about hundreds of points for a cube; there are in fact 8 points. You can use the LineMaker utility to create line data in the editor, which is covered in the LineMaker section of the Vectrosity Documentation file.

    --Eric
     
  37. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    121
    @Eric5h5 And what about the glitching lines on picture?
     
    Last edited: Nov 2, 2020
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    If you're moving the camera, you need to re-draw the lines every frame. If you're using Draw3D, then you can use Draw3DAuto instead.

    --Eric
     
    Pourya-MDP likes this.
  39. banksysan_unity

    banksysan_unity

    Joined:
    Feb 4, 2020
    Posts:
    12
    How do I have the lines drawn with Vectrocity in front of other UI elements?

    upload_2020-11-10_13-16-29.png

    All the lines here are all rendering behind the panel. I expected one to render behind it and one in front of it as per the order in the hierarchy.
     
  40. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    259
    Hi,

    Really amazed with your product. The demos have given me a few good ideas for current and future projects.

    At the moment I am using vectrosity to add a simple highlight as in the simple3dobject demo scene. I am using your code from the Simple3D3 script in order to implement something similar into my game. I have nearly got it, I am just having 1 issue and I cant find any documentation for what I think the solution is.

    I am trying to highlight objects in my scene, and only highlight objects I hover the mouse over. I have got that to work by adjusting your code from Simple3D3. The issue I am having is that the highlight remains once I move off the object. I think I am supposed to use

    Code (CSharp):
    1. VectorManager.VisibilityRemove(int objectnumber)
    I however do not know how to find out what the objectnumber is.

    Can anyone help?
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    The drawing order is indeed through the hierarchy:

    Screen Shot 2020-11-14 at 9.46.40 PM.png

    Given that the lines use Unity's UI system, I don't see how that would ever not work.

    The only VectorManager functions you should use are those in the reference guide; anything else is for internal use only. Probably the easiest way is just to turn the line on and off using OnMouseOver/Exit. Quick modification of Simple3D3:

    Code (csharp):
    1. using UnityEngine;
    2. using Vectrosity;
    3. using System.Collections.Generic;
    4.  
    5. public class Simple3D3 : MonoBehaviour {
    6.     VectorLine line;
    7.  
    8.     void Start () {
    9.         // Make a Vector3 array that contains points for a cube that's 1 unit in size
    10.         var cubePoints = new List<Vector3>{new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f)};
    11.      
    12.         // Make a line using the above points, with a width of 3 pixels
    13.         line = new VectorLine(gameObject.name, cubePoints, 3.0f);
    14.      
    15.         // Make VectorManager lines be drawn in the scene instead of as an overlay
    16.         VectorManager.useDraw3D = true;
    17.      
    18.         // Make this transform have the vector line object that's defined above
    19.         // This object is a rigidbody, so the vector object will do exactly what this object does
    20.         // "false" is added at the end, so that the cube mesh is not replaced by an invisible bounds mesh
    21.         VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None, false);
    22.     }
    23.  
    24.     void OnMouseOver () {
    25.         line.active = true;
    26.     }
    27.  
    28.     void OnMouseExit () {
    29.         line.active = false;
    30.     }
    31. }

    --Eric
     
    nobluff67 likes this.
  42. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    93
    I'm creating some lines with sth like this:
    m_horizonVectorLine = new VectorLine("HorizonCircle", m_HorizonPoints, 2.0f, LineType.Continuous);

    It all works fine, however all such objects are created on 'root level' in the scene view.
    It is possible when to specify a common parent when creating them in that way, so the scene-view doesn't get so cluttered?
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    You can use m_horizonVectorLine.rectTransform.SetParent.

    --Eric
     
    rboerdijk likes this.
  44. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    259
    This doesn't seem to work, can you see anything I am doing wrong?


    Code (CSharp):
    1.     private VectorLine vectrosity_Foundation;
    2.         cubePoints = new List<Vector3>{new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f)};
    3.         vectrosity_Foundation = new VectorLine("vectrosity_Foundation", cubePoints, 3.0f);
    4.         vectrosity_Foundation.rectTransform.SetParent(parentForBase);
    parentForBase is set to gameobject abc. vectrosity_Foundation is still in root.
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    You need to draw the line first so it's created in the scene before you set the parent.

    --Eric
     
    nobluff67 likes this.
  46. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    259
    Thanks for that.

    I am getting these "errors" in my scenes. I have also checked the _Simple3DObject scene and the errors are also there.

    Coroutine 'OnBecameInvisible' couldn't be started because the game object 'Cube2' is being deactivated!

    This is when you stop playing the scene. I am using 2019.4.11f1. There is no scene view tab and the game window is maximized.
     
    Last edited: Nov 20, 2020
  47. craigmann

    craigmann

    Joined:
    Sep 29, 2016
    Posts:
    15
    Hello Eric,
    I am using MakeCircle to create a circle around (and parented to its transform) a marker gameobject. Works great.
    Screen Shot 2020-11-25 at 11.00.28 AM.png

    Then, I pick out evenly spaced points along that line for which to get their location and place a gameobject there...

    // parent script...
    Code (CSharp):
    1. myLine = new VectorLine("DeviceUserLocationLine", new List<Vector3>(101), 5.0f, LineType.Continuous, Joins.Fill);
    2. myLine.drawTransform = this.transform;
    3. myLine.MakeCircle(Vector3.zero, Vector3.up, 10.0f, 100, 0);
    4.  
    5. var div = 101 / deviceUserList.Count;
    6. int  divInt = (int) div;
    7. for (int i = 0; i < deviceUserList.Count; i++)
    8. {
    9.     int pointer = divInt * (i + 1);
    10.     DrawDeviceUser(myLine.points3[pointer].x, myLine.points3[pointer].y, myLine.points3[pointer].z);
    11. }
    12. myLine.Draw3D();
    13.  
    // function that adds the new gameobject...
    Code (CSharp):
    1. public void DrawDeviceUser(float x, float y, float z)
    2. {
    3.     Vector3 pos = new Vector3(x, y, z);
    4.     GameObject newDeviceUser = Instantiate(expandedLocation, pos, Quaternion.identity);
    5.     newDeviceUser.transform.SetParent(this.transform);
    6.     // newDeviceUser.transform.localRotation = this.transform.rotation;
    7.     // newDeviceUser.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
    8. }
    // result
    Screen Shot 2020-11-25 at 11.02.35 AM.png
    It seems I am having some local to global issue here, do you have a recommendation to appropriately place a gameobject at a point on a 3D vectorline who's parent's transform has been changed?

    // parent
    Screen Shot 2020-11-25 at 11.14.14 AM.png

    Maybe you already have a demo doing something similar I have not found yet?

    Thank you for your time and your awesome asset... (have bought it at least 3 times with companies and self. :D)
     
  48. Artpen

    Artpen

    Joined:
    Jan 24, 2015
    Posts:
    162
    Hi Eric,

    Just wondering if Vectrosity has tools for runtime handles? I need to be able to add/remove/manipulate handles/points of the Bezier curve at run time.

    Thank you
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,307
    I couldn't reproduce that right now, but if they only occur when stopping play mode, they wouldn't have any effect so you can ignore them.

    I generally advise against parenting VectorLines, and using VectorLine.drawTransform instead. It avoids a lot of issues like this.

    Runtime handles are easy enough; check the Curve demo.

    --Eric
     
  50. Artpen

    Artpen

    Joined:
    Jan 24, 2015
    Posts:
    162
    Thank you Eric
     
unityunity