Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Vectrosity - Fast and Easy Line Drawing

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

  1. adentutton

    adentutton

    Joined:
    Mar 24, 2013
    Posts:
    34
    Hi Eric

    Such a great tool! Im using it for a bit of a statistic tracking for my sport sim and currently I have everything drawing in the right spots with the effects shown in the picture attached

    example lines.png

    Ive setup all the various End Caps that Ill need in my start function and below is my code. Im not sure if Im drawing double lines or something wrong with the texture Im using to create the line? Below is my code

    Code (CSharp):
    1. VectorLine.SetEndCap ("Serve 6", EndCap.Back, blackLine, square6); //in Start function along with all the other line possibilities
    2.  
    3. VectorLine statLine = new VectorLine("Line", currentStatisticPoints, 10f, LineType.Continuous);
    4.         statLine.SetCanvas(statPanel); //assign to the UI panel
    5.         statLine.endCap = "Serve 6"; //use endCap parameters
    6.         statLine.Draw();
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    The best thing for performance in general is to only update the lines when needed, rather than every frame.

    That seems fine. What is the issue you're having?

    --Eric
     
  3. adentutton

    adentutton

    Joined:
    Mar 24, 2013
    Posts:
    34
    The texture I have selected is highlighted in the example below example lines selection.png

    The effect I am looking to get a line of the same colour as the end cap which is thinner than the end cap size (with the alpha texture on the top and bottom but I don't have any white in any of the textures? Thats what made me think I've drawn another white line on top!
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Maybe you have? :) Do other textures look right?

    --Eric
     
  5. cwule

    cwule

    Joined:
    May 23, 2016
    Posts:
    14
    In the spline Demo I want to update the spline when moving the spheres at runtime.
    Putting the following Update function in myspline.cs only shows straight lines being updated when moving a sphere but no spline interpolation.
    Code (CSharp):
    1.  
    2. function Update() {
    3.     i = 1;
    4.     for (sp in splinePoints) {
    5.         obj = GameObject.Find ("Sphere"+(i++));
    6.         spline.points3[i-1] = obj.transform.position;
    7.         Debug.Log(spline.points3[i-1]);
    8.     }
    9.     pointsArray = spline.points3.ToArray();
    10.     spline.MakeSpline(pointsArray, segments, loop);
    11.     spline.Draw3D();
    12. }
    How can I update the spline curve?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    There would need to be many points in the line in order to make a curve. The number of points in the spline should be fewer than the total points in the line.

    --Eric
     
  7. cwule

    cwule

    Joined:
    May 23, 2016
    Posts:
    14
    Thanks for the quick answer. Unfortunately I am not quite sure I understand. I have 9 spline points (the same spheres as in the spline demo) and 250 segments (also same as in demo). So doesn't that mean that I have more points in the line than spline points?

    This is the complete script. When moving a sphere around during runtime, the lines get updated. However, the lines are all straight, I would like them to be curved like in the spline demo.

    Code (CSharp):
    1. #pragma strict
    2. import Vectrosity;
    3. import System.Collections.Generic;
    4.  
    5. var segments = 250;
    6. var loop = true;
    7. var usePoints = false;
    8. var splinePoints : List.<Vector3>;
    9. var i = 1;
    10. var obj : GameObject;
    11. var len = 0;
    12. var spline : VectorLine;
    13. var pointsArray: Vector3[];
    14.  
    15. function Start () {
    16.     splinePoints = new List.<Vector3>();
    17.     var i = 1;
    18.     obj = GameObject.Find ("Sphere"+(i++));
    19.     while (obj != null) {
    20.         splinePoints.Add (obj.transform.position);
    21.         obj = GameObject.Find ("Sphere"+(i++));
    22.     }
    23. spline = new VectorLine("Spline", new List.<Vector3>(segments+1), null, 2.0, LineType.Continuous);
    24. }
    25.  
    26. function Update() {
    27.     i = 1;
    28.     for (sp in splinePoints) {
    29.         obj = GameObject.Find ("Sphere"+(i++));
    30.         spline.points3[i-1] = obj.transform.position;
    31.     }
    32.     pointsArray = spline.points3.ToArray();
    33.     spline.MakeSpline(pointsArray, segments, loop);
    34.     spline.Draw3D();
    35. }
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    You're making the points in the line be the same as the sphere positions, when the array used for making a spline should be entirely separate.

    --Eric
     
  9. adentutton

    adentutton

    Joined:
    Mar 24, 2013
    Posts:
    34
    Hi Eric

    On the last reply I am drawing 2 lines, silly me! I have changed the size of my Main Camera plus changed from Screen Space - Camera to Overlay and now I am getting less than desirable results for my lines! In the editor they appear to be fine but I get these results building to iPad

    image1-3.PNG

    Attempting to change the canvas camera give me an error message though?

    Code (CSharp):
    1. statLine.SetCanvasCamera(Camera.main);
    I have also placed the below line in the Start function with no luck

    Code (CSharp):
    1. VectorLine.SetCanvasCamera(Camera.main);
     
    Last edited: Jan 29, 2017
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    SetCameraCanvas is a static function; you don't use it with a specific VectorLine. I'd recommend using ScreenSpaceOverlay unless you have a specific reason for using ScreenSpaceCamera. Make sure you've programmed the lines to be properly resolution-independent by resizing the game view in the editor from time to time and ensuring the lines still look correct.

    --Eric
     
  11. adentutton

    adentutton

    Joined:
    Mar 24, 2013
    Posts:
    34
    Thanks for the reply Eric

    At the moment when I have the lines drawn with the iPad Wide view the lines draw perfectly as expected but I don't have the same results when building? Is that a problem just with how I'm choosing to draw the lines onto the screen? At the moment Im just referencing what points the actions happened in game and drawing them from a reference GameObject at a similar position to the game court (on the court is at 0,0 and the same relative position on the UI)
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Using iPad Wide doesn't necessarily mean the game view is actually using the resolution of an iPad (just the aspect ratio), so make sure you're actually duplicating the exact pixel resolution of an iPad in the editor.

    --Eric
     
  13. adentutton

    adentutton

    Joined:
    Mar 24, 2013
    Posts:
    34
    As always coming up with the solution! With your help Ive also created the code to scale the line depending on the screen resolution too!
     
  14. Liviuss

    Liviuss

    Joined:
    Apr 2, 2014
    Posts:
    88
    Hi Eric,

    In one of my project i'm working on drawing the path of the gameobject along the navmesh path.
    In order to get better performance i want the lines to be be batched since they use the same material but they're not.

    What i do:
    1. Init lines

    Code (CSharp):
    1.  
    2. public Texture dirTex;
    3. public float dirWidth;
    4. public float dirTextureScale;
    5. public Material dirMat;
    6. public List<Vector3> linePoints = new List<Vector3> ();
    7. VectorLine directionLine = new VectorLine ("DirLine", linePoints, dirTex, dirWidth, LineType.Continuous, Joins.Weld);
    8. directionLine.material = dirMat;
    9. directionLine.textureScale = dirTextureScale;
    10. directionLine.continuousTexture = true;
    2. Update points during movement and redraw line
    (linePoints ->Clear/Add new points)
    Code (CSharp):
    1.  
    2. directionLine.points3 = linePoints;
    3. directionLine.Draw3D ();
    4.  
    Material is additive with geometry render queue. And camera is set with cCamera.opaqueSortMode = UnityEngine.Rendering.OpaqueSortMode.NoDistanceSort;

    I don't understand why frame debugger still show me separate drawcalls for each line. Can you explain me if batching can be achieved or not ?

    Thanks

    P.S. I'm using Unity 5.5.0p4 and latest vectrosity version from store.

    Update1. If i select the gameobjects with rendered lines in the inspector(in pause mode) and assign the material directly then they do get batched.

    Update2. The problem is the SetVectorLine function where you instantiate a new material for each object so the MeshRenderer.sharedMaterial has no effect. Solved by reusing material instead of new().
    Code (CSharp):
    1. public void SetVectorLine (VectorLine vectorLine, Texture tex, Material mat) {
    2.         gameObject.AddComponent<MeshRenderer>();
    3.         gameObject.AddComponent<MeshFilter>();
    4.         m_vectorLine = vectorLine;
    5.         m_material = new Material (mat);
    6.         m_material.mainTexture = tex;
    7.         //GetComponent<MeshRenderer>().sharedMaterial = m_material;
    8.         GetComponent<MeshRenderer>().sharedMaterial = mat;
    9.         SetupMesh();
    10.     }
     
    Last edited: Jan 31, 2017
  15. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I had a working program using vectrosity 4 and unity 5.1.2. I am upgrading that project to vectrosity 5 and unity 5.5. I have a scene where I draw a bunch of lines (using Draw3DAuto), but only some of the lines show up. I had a similar issue in the original project that was solved with VectorLine.canvas3D.sortingOrder = 1. That is no longer available. What do you suggest I try to get all of the lines showing?
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    3D lines in Vectrosity 5 are meshes that exist in the scene and don't use a canvas. Offhand I don't know of any causes for lines not showing up if they're supposed to since I'm not aware of this happening, but you can maybe try changing the shader used in the line material. Otherwise I'd need more details to go on.

    --Eric
     
  17. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    Hi Eric,

    I'm using 3D vectorlines and worldspace cavases. The canvases consistently occlude the vectorlines when they coincide in the camera view. I'd like the vectorlines to render in front of the canvases when they are closer to the main camera than the canvases, but can't figure out a way to do that. I see that DrawDepth doesn't work with 3D lines.

    Also, I'm drawing a 3D vectorline on one of the canvases using DrawTransform. But that line is also occluded by the canvas color, which is partly opaque. I guess that's the same problem.

    Any help is much appreciated!
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    VectorLines shouldn't be put on world space canvases, since that's not supported. I tried a regular 3D line using the default material, where a world canvas was located at z=6 and the line is z=5:

    worldcanvas1.jpg

    Changing the line points' z to 7 and redrawing gets this:

    worldcanvas2.jpg

    So at least with the default materials/shaders, occlusion seems to work as expected. If you're using custom shaders, that could likely affect how ordering works.

    --Eric
     
  19. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    Thanks, Eric. Knowing that the canvases should not be occluding the vectorlines was actually the information I needed. Some of the things I was doing with sorting layers were causing the occlusion, and it's (mostly) fixed now.
     
  20. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    Eric, I'm having difficulty with Vectorline.Destroy. I am creating vectorlines within a method and adding these to a list of vectorlines. I can use vectorline.Destroy(listname) to destroy all of the lines; that works properly. But I also want to be able to destroy just the last vectorline in the list-- so an 'undo', basically. Both Vectorline.Destroy (ref listname) and Vectorline.Destroy(listname) throw errors.

    I imagine I could use GameObject.Find to get a vectorline; but as my existing method creates vectorlines with the same name, that would get a bit complicated. Is there an easier way to destroy just one vectorline within a list? Thanks.
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    GameObject.Find won't work; you need to use the actual VectorLine object. VectorLine.Destroy works with a List without errors; you don't use ref unless you're passing in a single VectorLine. So I suspect you have some syntax error.

    --Eric
     
  22. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    Eric, I'm sorry, I didn't type in the sample code correctly. Here's another try. I have a list of vectorlines called displayLines, and I'm trying to destroy not all of the lines, but the last line in the list.

    Code (CSharp):
    1.     public void UndoStep(){
    2.  
    3.         int last = displayLines.Count - 1;
    4.         VectorLine.Destroy (ref displayLines [last]);
    5.         displayLines.RemoveAt (last);
    6.         displayLines.TrimExcess ();
    7.     }
    Importing this script to unity generates "error CS0206: A property, indexer or dynamic member access may not be passed as `ref' or `out' parameter". Removing the "ref" generates the error "missing the ref modifier".

    Thanks for your help, and your patience, which you have displayed many, many times on this thread.
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    In that case, you'd need to assign the list entry to a variable:

    Code (csharp):
    1. var tempLine = displayLines[last];
    2. VectorLine.Destroy (ref tempLine);
    I'd also suggest not using TrimExcess; it's rarely actually beneficial.

    --Eric
     
  24. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    That works! Thanks again!
     
  25. dradb

    dradb

    Joined:
    Jan 10, 2015
    Posts:
    68
    How would I send a graph drawn with Vectrosity to a printer?

    Thank you.
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    You could take a screenshot and print that, but other than that I have no idea.

    --Eric
     
  27. echuang98

    echuang98

    Joined:
    Oct 21, 2015
    Posts:
    17
    Hi Eric,
    I put a Line.cs which creates a VectorLine on to an empty gameObject, and then make it a prefab.
    And then, I instantiate the prefab and active it when I need it with my object pool script.
    I notice that every time a prefab is activated, I get one more SetPass Call. And soon I got so many SetPass Calls:(
    It would be wonderful if you could tell me what happened. Thank you!

    Code (CSharp):
    1. public class Line : MonoBehaviour {
    2.  
    3.     public float width = 1f;
    4.  
    5.     // If postion.z > maxZ, the line will be deactivate.
    6.     public float maxZ = 10;
    7.  
    8.     VectorLine line;
    9.     List<Vector3> linePoints;
    10.  
    11.     void Awake()
    12.     {
    13.         Init();
    14.     }
    15.  
    16.     void Update () {
    17.         DeactivateByPos(maxZ);
    18.     }
    19.  
    20.     void LateUpdate()
    21.     {
    22.      
    23.     }
    24.  
    25.     void Init()
    26.     {
    27.         // The real points' position will be set when spawned.
    28.         linePoints = new List<Vector3> { new Vector3(0, 0.5f, 0), new Vector3(0, -0.5f, 0) };
    29.         line = new VectorLine("Drawed Line", linePoints, width, LineType.Discrete);
    30.         line.drawTransform = transform;
    31.         line.Draw3DAuto();
    32.     }
    33.  
    34.     // Called by PooledLineSpawner's Spawn()
    35.     public void SetLineInfo(Vector3 _center, float _length, float _width)
    36.     {
    37.         transform.position = _center;
    38.         transform.localScale = Vector3.one * _length;
    39.         line.lineWidth = _width;
    40.     }
    41.     void OnEnable()
    42.     {
    43.         line.active = true;
    44.     }
    45.  
    46.     void OnDisable()
    47.     {
    48.         line.active = false;
    49.     }
    50.  
    51.     void DeactivateByPos(float _z)
    52.     {
    53.         if(transform.position.z > _z)
    54.             gameObject.SetActive(false);
    55.     }
    56. }
     

    Attached Files:

    Last edited: Feb 16, 2017
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    I expect you're creating a new VectorLine every time the object is activated. You should only create the VectorLine once. If you're going to pool, you should be pooling VectorLines themselves, rather than objects that create VectorLines.

    --Eric
     
  29. echuang98

    echuang98

    Joined:
    Oct 21, 2015
    Posts:
    17
    Hi Eric,
    I did a simple test (below is the code) in an empty scene, and I notice that if I create 1 VectorLine, the SetPass call = 2.
    If I create 5 VectorLine, the SetPass call = 6.
    So creating one VectorLine will create one SetPass call?
    What I want to do is to spawn many lines, and they will move along the z axis, and will get deactivated when their position.z > 10. When I need them I spawn them again and they move as they did until get deactivated again.
    Is there any way I can have many VectorLines in a scene but not have many SetPass calls?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Vectrosity;
    5.  
    6. public class LineSetPassCallTest : MonoBehaviour {
    7.  
    8.     public int amount = 5;
    9.     List<Vector3> linePoints;
    10.  
    11.     void Start () {
    12.  
    13.         linePoints = new List<Vector3> { Vector3.zero, Vector3.one };
    14.  
    15.         for(int i = 0; i < amount; i++)
    16.         {
    17.             VectorLine line = new VectorLine("Line" + i, linePoints, 2, LineType.Discrete);
    18.             line.drawTransform = transform;
    19.             line.Draw3DAuto();
    20.         }
    21.     }
    22.  
    23. }
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Hi, I'd recommend creating a single VectorLine using LineType.Discrete, and change the points making up the line as needed.

    --Eric
     
  31. echuang98

    echuang98

    Joined:
    Oct 21, 2015
    Posts:
    17
    I will try this solution, thank you!
     
  32. flairzguru

    flairzguru

    Joined:
    Jan 29, 2017
    Posts:
    6
    I wanted to know is there any way to use "Line Width" for multiple resolution so that I could make a responsive design.Currently same line width is applied for all resolution devices so it create problem of either distortion or expansion.
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    For that case I'd suggest using Screen.dpi in a calculation for the line width, rather than a specific number.

    --Eric
     
  34. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    7
    Hey Eric,

    I'm getting some odd errors with Unity generating "!IsFinite(outDistanceSort" for vector lines with negative values. This seems to be fairly consistent in both Unity 5.4.0 and 5.5.5.

    I'm basically drawing lines between the transform position of parent Renderer A (origin) and child Renderer B (target). The hierarchy is relatively complex, and I am modifying the vector points by other variables, but the resulting start and end points of the line seem sane, and the problem persists even if just take those positions and do not modify them. In one example, I decided to use the resultant numbers I got to draw a static line:

    Code (CSharp):
    1. // Target parent generates error regardless whether it's 0,0,0 or in a more complex hierarchy.
    2. // In this case it's just a GameObject we've already set up.
    3. public void CreateStaticLine()
    4. {
    5.     Vector3 pointA  = new Vector3(0.8f, -0.8f, 0.0f);
    6.     Vector3 pointB = new Vector3(2.8f, -2.8f, 0.0f);
    7.  
    8.     var points = new List<Vector3>{pointA, pointB};
    9.  
    10.     var line = new VectorLine ("Vector Line", points, 2.0f);
    11.  
    12.     VectorManager.ObjectSetup (targetParent, line, Visibility.Dynamic, Brightness.None);
    13.  
    14.     // This has already been setup at scene start, but including it here anyway
    15.     VectorManager.useDraw3D = true;
    16.  }
    This creates the errors. It doesn't occur if I use Visibility.Always (but I prefer not to incur the cost of always rendering the line), or if I remove the negative sign of the Vector3 y values.

    Is there anything I am doing obviously wrong? I apologise in advance if I've missed something - I'm a UI designer by trade and have only been coding on/off for two months.

    Thanks in advance for your help!

    Chris

    (PS: I've got a relatively simple project file I could send your way if you need more details.)
     
    Last edited: Feb 18, 2017
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Try creating and drawing a VectorLine normally instead of using ObjectSetup. The purpose of ObjectSetup is to replace an object's renderer with a VectorLine.

    --Eric
     
  36. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    7
    Thanks for your answer Eric! Using Draw3D option does work without generating the errors, and I'll probably fall back to that if there's no other option.

    However, my use case is as follows: I have a planet which is orbited by several space stations. Once a player sees the planet, we use Vectrosity to highlight the stations, but these only show up gradually as the player progresses through the game and are hidden at the beginning of play.

    Reading the documentation, ObjectSetup seems ideal for this - as I hide a parent game object, the child gameObject with an attached renderer (which is now replaced by the line) is also hidden. And if we need to destroy the object, the same occurs.

    I could of course just show/hide the line by using the OnEnable and OnDisable methods and a reference to the line, but I don't see how my use of ObjectSetup is different from what the coding guide implies you can use it for (as my target gameObject has a placeholder renderer and filter)? If you could elaborate on what breaks it, that'd be amazingly helpful.
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    I'm not really sure what would break (and theoretically it shouldn't); possibly it has something to do with having a complex hierarchy.

    --Eric
     
  38. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    7
    After some more digging, it seems that setting objectSetup's makeBounds argument to false will not cause the error to occur at all (even when using Visibility.Dynamic.)

    So for now, I'm just attaching an empty renderer to a gameObject that holds the vector line and calling objectSetup like this. Seems to work fine.
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    OK, that makes sense; with an empty object there would be no bounds.

    --Eric
     
  40. AurochChris

    AurochChris

    Joined:
    Jan 7, 2014
    Posts:
    7
    Apologies, but the error did occur when attaching it with TRUE to a cube created in Unity. Just in case that is something you wanted to look at.

    Thanks again!
     
  41. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    I'm not able to replicate that (also, true is the default behavior). See the included demos, e.g. Simple3D.

    --Eric
     
  42. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    31
    Hi, I am really amazed at how simple and powerful Vectrosity is, thank you!

    I am running into a weird situation drawing a squiggly random line where segments randomly go back to 0,0 like in the attached screenshot.

    Code (CSharp):
    1.  
    2. squiggle = new VectorLine("Line", new List<Vector2>(), 2.0f, LineType.Continuous, Joins.Weld);
    3. squiggle.lineWidth = 4f;
    4. curPosition = Input.mousePosition;
    5. Debug.Log(curPosition);
    6. squiggle.points2.Add(curPosition);
    7.  
    Thanks!
    David
     

    Attached Files:

  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Hi, I'm not able to reproduce anything like that. Have a look at the included DrawLinesMouse demo script for an example of freehand drawing with a mouse.

    --Eric
     
  44. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    31
    I slowed down the points adding and it's working as expected now, thanks.

    Another question. Is there a way to use a tiled image as the line texture, say like drawing a rough-looking rope or some other long repeating pattern?
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Use VectorLine.textureScale.

    --Eric
     
  46. GrumpyFour

    GrumpyFour

    Joined:
    Jan 12, 2016
    Posts:
    17
    Hi Eric,

    I'm having some more odd occlusion behaviors. In this case VectorLines seem to be rendering behind specific meshes. What's particularly strange is that this occurs only in some scenes in my application, where I'm using the same prefabs and the same scripts across the different scenes. All of the objects involved are in the Default layer, and the VectorLines are set to use the same layer as the ray collision quad, which is in the Default layer. In the attached screenshots you can see the difference between two scenes: in one there are two VectorLines that render properly in front of the mesh, but in the other the lines are barely visible once they overlap with the mesh (they are not completely hidden, but are barely visible). I've checked everything I can think of regarding differences between the two scenes, but I'm stumped.

    Screen Shot 2017-02-23 at 4.42.16 PM.png Screen Shot 2017-02-23 at 4.42.36 PM.png
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    Is this using Draw3D? If so, that makes lines just standard meshes, so the draw order depends entirely on the usual rules for that (namely the shader). Inconsistent results are usually the result of undefined behavior, i.e. the shader isn't defining what's drawn on top so it could go either way.

    --Eric
     
  48. flairzguru

    flairzguru

    Joined:
    Jan 29, 2017
    Posts:
    6
    is there anyway to use VectorLine's side edges as some wall so that I could restrict my object's motion between two side edges of line.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,156
    I'm not quite sure what you mean by "side edges", but possibly VectorLine.collider is what you're looking for.

    --Eric
     
  50. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,046
    For this 2D prototype I am working on I need to draw some lines but found that they stay on the spot when I move my camera around.

    So I did
    Code (CSharp):
    1. VectorLine.canvas.renderMode = RenderMode.WorldSpace;
    and it seems to work fine. The docs however states to not do this. Is there a better way I can get the lines to move with the scene objects (sprites) they are "connected to visually"?

    [edit] nvm.. seems I'm suppose to make use of drawTransform.
     
    Last edited: Feb 24, 2017