Search Unity

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

Vectrosity - Fast and Easy Line Drawing

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

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're already having a canvas's parent set to another object, you can do the same thing with VectorLine.canvas3D.

    --Eric
     
  2. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    I need help. How do I avoid my texture to morph? I am using a circle texture, but when I play the game it would look like this



    I expect to have unmorphed "circle" dots.

    This is my code:

    Code (CSharp):
    1. rectLine = new VectorLine("Rectangle", points, lineMaterial, lineWidth, LineType.Continuous, Joins.Weld);
    2. rectLine.textureScale = 1f;
    3. rectLine.Draw();
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's a limitation of UV mapping a single stretched quad (not just in Unity but in general); if you use more points so there are more quads, it will look much better.

    --Eric
     
  4. douglasg14b

    douglasg14b

    Joined:
    Oct 2, 2014
    Posts:
    34
    Thanks for the reply Eric.

    However I seem to be having issues with multiple canvases, between having the wrong ID's show up in the hierarchy (Debugging shows .canvasID as being 1, and canvas3D_02 shows up and a canvas_1 shows up as well) , canvases being undestroyable (VectorLine.Destroy doesn't remove the canvas, so I tried destroying their gameobject), transforms being offset to the upper left with transforms and offsets of 0, and the lines being set to a transform outside of their canvas.... I'm lost .

    I have tried just about everything I can think of to get multiple canvases to work, but I am unable to get it to function. Rather than writing up a report of the last couple hours, and the dozens of different "things" I have tried. How would you solve the following problem:

    You have multiple units. Each one needs it's own circle when selected, you can select multiple units at a time. The circle needs to be a child of each unit so that it can move and rotate with it's parent without calling Draw3d() again. The circle needs to disappear when the units are deselected and reappear when re-selected. These units may or may not be destroyed at any given point and time.

    My Current code (It's patched together rather roughly for now):

    Code (CSharp):
    1.     private void DrawStrategicCircle()
    2.     {
    3.         Vector3[] myLinePoints = new Vector3[251];
    4.         attackRangeLine = new VectorLine(name + "AttackRange Circle", myLinePoints, lineMaterial, 5, LineType.Continuous);
    5.         attackRangeLine.MakeCircle(transformV.position, canAttackObject.AttackRange * 5, 250);
    6.         attackRangeLine.SetColor(Color.red);
    7.  
    8.         int canvasIndex;
    9.         if(VectorLine.canvases3D[0].transform.childCount == 0)
    10.         {
    11.             canvasIndex = VectorLine.canvases3D.Count - 1;
    12.             attackRangeLine.canvasID = canvasIndex;
    13.             attackRangeLine.rectTransform.parent = transformV;
    14.             VectorLine.canvases3D[canvasIndex].transform.SetParent(transformV);
    15.             VectorLine.canvases3D[canvasIndex].transform.localPosition = new Vector3(0, 0, -1);
    16.             attackRangeLine.Draw3D();
    17.         }
    18.         else
    19.         {
    20.             canvasIndex = VectorLine.canvases3D.Count;
    21.             attackRangeLine.canvasID = canvasIndex;
    22.             attackRangeLine.rectTransform.parent = transformV;
    23.  
    24.             attackRangeLine.Draw3D();
    25.  
    26.             VectorLine.canvases3D[canvasIndex].transform.SetParent(transformV);
    27.             VectorLine.canvases3D[canvasIndex].transform.localPosition = new Vector3(0, 0, -1);
    28.         }
    29.     }
    I appreciate any help you can give me. The above code works for the first click on each unit. If I deselect them and go to select them all again all of the lines get assigned under the highest number canvas (If there are 5 units I get a VectorCanvas3d_05 under the 5th unit, and VectorCanvas through VectorCanvas_04 as top-level canvases in the hierarchy).
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I couldn't quite follow what that's doing. I tried this code, with two cubes initially at (0, 0, 0):

    Code (csharp):
    1. var ob1 : Transform;
    2. var ob2 : Transform;
    3.  
    4. function Awake () {
    5.     var line1 = new VectorLine("L1", [Vector3.zero, Vector3.one], null, 2.0);
    6.     line1.Draw3D();
    7.     VectorLine.canvases3D[0].transform.SetParent (ob1);
    8.    
    9.     var line2 = new VectorLine("L2", [Vector3.zero, Vector3.one], null, 2.0);
    10.     line2.canvasID = 1;
    11.     line2.Draw3D();
    12.     VectorLine.canvases3D[1].transform.SetParent (ob2);
    13.     ob2.Translate (Vector3.right * 2);
    14. }
    Which results in this:

    Screen Shot 2015-03-26 at 11.51.42 PM.png

    --Eric
     
  6. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am new to Vectrosity. I am trying to use 3D lines. If I take the _Simple2DLine demo scene and modify the script Line as follows, I don't see a line. What am I doing wrong?

    Code (javascript):
    1.  
    2. //UsethismethodifyouneedmorecontrolthanyougetwithVector.SetLine
    3. importVectrosity;
    4.  
    5. functionStart () {
    6. //MakeVector2array; inthiscasewejustuse2elements...
    7. varlinePoints = [Vector3(0, Random.Range(0, Screen.height),0), // ...oneontheleftsideofthescreensomewhere
    8. Vector3(Screen.width-1, Random.Range(0, Screen.height),0)]; // ...andoneontheright
    9.  
    10. //MakeaVectorLineobjectusingtheabovepointsandthedefaultmaterial, withawidthof2pixels
    11. varline = VectorLine("Line", linePoints, null, 2.0);
    12.  
    13. //Drawtheline
    14. line.Draw3D();
    15. }
    16.  
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Using screen coordinates for Vector3 points won't work; you need to use world space coordinates.

    --Eric
     
  8. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Hello! How do I make the line scale with different resolutions? Currently, the line looks really big in small resolutions (editor), and really small in really big resolutions (Note 3, 1080p).
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'd recommend using Screen.dpi when calculating line width.

    --Eric
     
  10. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    I multiplied my line width with the Screen.dpi but it still not scaling properly. The proportion is still different. This can also be seen when I scale my game view up and down. Was I supposed to only multiply Screen.dpi? I've never used dpi before. :(
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you use, say, 0.05 * Screen.dpi, it would have the same visual width on any screen. If the dpi was 200 you'd get 10, and if the dpi was 100 you'd get 5. 10 pixels on a 200 ppi screen looks the same as 5 pixels on a 100 ppi screen.

    --Eric
     
  12. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Ok, I understand now how dpi works. Unfortunately, that isn't what I want to achieve.

    I need my line width to scale relative to another object in the scene. Like scaling a photo while preserving its aspect ratio. Do you know how I would achieve that?

    Edit: In other words, I want the width to be relative to the world (space).
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not really following what you mean, sorry.

    --Eric
     
  14. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Say I set the line width to be 1 unit in world space, I want it to be 1 unit across different resolutions too. Does that make sense?



    I want it to look like this across different devices/resolutions. Keeping the proportion with the cube.
     
    Last edited: Mar 28, 2015
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vectrosity uses pixels as line width measurement, so you'd have to find some way to convert. Personally I don't really know; I guess it would depend on how far the cube is from the camera.

    --Eric
     
  16. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Would drawTransform be of any help in this case?
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, you use drawTransform to link a transform to a VectorLine.

    --Eric
     
  18. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Since it is using pixels, that means it is in screen space, right? I will try converting it from screen space to world space using the main camera. Let's see how that will go.

    Edit: or world space to screen space.
     
  19. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am having some issues when a uGUI element is added to a scene. A line drawn with Vectrosity is blocked by a uGUI button unless it is moved way back in the scene. I have a package exported to demonstrate this. I just modified one of the included examples. Can I send it to you?
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes (send me a PM), but you should be able to use the canvas's sorting order.

    --Eric
     
  21. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am doing Draw3D() with a continuous line. If I don't use any endcaps, Joins.Fill works fine. If I use endcaps, Joins.Fill doesn't work. Joins.Weld will work, but I'd rather not take the performance hit.

    Just draw a line with three points and a 90 degree turn. Add the sample arrow endcaps and use Joins.Fill.
     
  22. betaFlux

    betaFlux

    Joined:
    Jan 7, 2013
    Posts:
    112
    Hello, I'm using Unity 5 Personal Edition and I'd like to know if there is a way to draw a line along a Vector3 pathfinding path, which of course dynamically changes at runtime.

    My question is, if I do this:

    Code (CSharp):
    1.  
    2. VectorLine vectorLine = new VectorLine("line", path, material, 3, LineType.Continuous, Joins.Weld);
    3.  
    4. void Update
    5. {
    6.     vectorLine.Draw3D();
    7. }
    8.  
    ... how do I assign the points of a new path to the vectorLine?

    Besides that, could somebody please explain how I can make the line start position always stay at the object which walks the path? Thank you!
     
    Last edited: Mar 31, 2015
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use the line.points3 list to change points at runtime. If you use line.drawTransform, you can link a transform to a line.

    Oops, you're right, sorry about that. I'll fix it.

    --Eric
     
  24. betaFlux

    betaFlux

    Joined:
    Jan 7, 2013
    Posts:
    112
    Thanks for your time Eric, but I guess I'm missing some essential knowledge here... I tried
    Code (CSharp):
    1.  
    2. void Update()
    3. {
    4.     vectorLine.points3 = new List<Vector3>(agent.path);
    5. }
    6.  
    But 'points3' is a read-only variable. How do I mess with the points instead? Do I have to re-create the line every frame?

    EDIT:

    Another problem is, that if I use line.drawTransform in my 2D Top Down game, not only the first point but the complete line is way off the position of the assigned transform but relatively follows the character's movement.

    Anything I can do about the offset?
     
    Last edited: Mar 31, 2015
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, do not recreate the line, and don't create a new list every frame. Just change line.points3. You can add, remove, and change the points. Create the initial list when you create the VectorLine. For the offset, change the points in the line to be what you want.

    --Eric
     
  26. dttngan91

    dttngan91

    Joined:
    Nov 21, 2013
    Posts:
    80
    Hi Eric,
    I am faced with a performance issue when SetEndCap. It takes more than 12MB of Texture2D with multiple instances even though I call it once. How can I reduce the texture memory allocated from SetEndCap? Screen Shot 2015-04-02 at 10.24.55 AM.png
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It doesn't seem to be related to SetEndCap, since I don't have that in the profiler when I run the EndCap demo scene.

    --Eric
     
  28. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
    What is the difference between width of 3d and 2d lines?
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    None, they both use pixels as the width measurement.

    --Eric
     
  30. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    I am using Vectrosity 3 with unity3d 4.3.
    In a project like "EndCap" which is in Vectrosity Sene folder, I want to
    have a big arrow with thin Spline but when I try to reduce my spline diameter
    my arrow becomes small too.I try to use a biger arrow texture but I think,
    the main code make it resize (make it smaller) to be match with my Spline.
    so what should I do?
     
  31. Seraph4

    Seraph4

    Joined:
    Jun 5, 2013
    Posts:
    1
    Hey Eric. I've got multiple developers working on a project. Will we each have to buy a copy of Vectrosity to use it?
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It depends where you buy it from; my site has pro and team licenses available.

    --Eric
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vectrosity 4.1.3 is out:

    Changes:
    • Even numbers are enforced with VectorLine.endPointsUpdate, when used with discrete lines.

    Fixes:
    • Back end caps are colored correctly if using VectorLine.smoothColor = true.
    • Fixed VectorLine.endPointsUpdate not working correctly with discrete lines when using even numbers.

    However, as it turns out, the "bug" with using end caps and Joins.Fill was not a bug; it's just that Joins.Fill only really works with solid non-textured lines. So end caps work fine with Joins.Fill after all: use a material for the line that has no texture. Example of end caps with Joins.Fill:

    Screen Shot 2015-04-03 at 5.19.03 PM.png

    --Eric
     
  34. iOSGamer

    iOSGamer

    Joined:
    Apr 6, 2015
    Posts:
    2
    Hey Eric.. I just purchased Vectrosity today as I wanted to do a realtime graph controlled by user input and I am very new to Unity programming.

    I used the following code to draw a moving graph.
    Code (CSharp):
    1. public class Graph : MonoBehaviour
    2. {
    3.     //the buffer contains 100 points
    4.     private CircularBuffer<Vector3> buffer = new CircularBuffer<Vector3>(30);
    5.  
    6.     private VectorLine line;
    7.     private Vector3 point;
    8.  
    9.     private float x = -5f;
    10.     private float increment = .1f;
    11.     int count = 0;
    12.  
    13.  
    14.     void Start()
    15.     {
    16.         //initial points
    17.         for (int i = 0; i < buffer.Count; i++)
    18.         {
    19.             x += increment;
    20.          
    21.             point = new Vector3(x, Mathf.Sin(x));
    22.             buffer.Add(point);
    23.         }
    24.      
    25.         line = new VectorLine("MyLine", buffer.ToArray(),null, 2.0f, LineType.Continuous);
    26.         line.Draw3DAuto(Mathf.Infinity);
    27.     }
    28.  
    29.  
    30.     void Update()
    31.     {
    32.  
    33.  
    34.         x += increment;
    35.         count++;
    36.         //add the points to the buffer (old points get dequeued)
    37.         point = new Vector3(x, Mathf.Sin(x));
    38.         buffer.Add(point);
    39.      
    40.         //move the line object
    41.         Vector3 pos = line.rectTransform.position;
    42.         pos.x -= increment;
    43.         line.rectTransform.position = pos;
    44.  
    45.         line.points3.RemoveAt (0);
    46.         line.points3.Add (point);
    47.  
    48.     }
    49. }
    50.  
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. public class CircularBuffer<T>
    6. {
    7.     private Queue<T> queue;
    8.     private int count;
    9.  
    10.     public CircularBuffer(int count)
    11.     {
    12.         queue = new Queue<T>(count);
    13.         this.count = count;
    14.     }
    15.  
    16.     public void Add(T obj)
    17.     {
    18.         if (queue.Count == count)
    19.         {
    20.             queue.Dequeue();
    21.             queue.Enqueue(obj);
    22.         }
    23.         else
    24.             queue.Enqueue(obj);
    25.     }
    26.  
    27.  
    28.     public T Read()
    29.     {
    30.         return queue.Dequeue();
    31.     }
    32.  
    33.     public T Peek()
    34.     {
    35.         return queue.Peek();
    36.     }
    37.  
    38.     public T[] ToArray()
    39.     {
    40.         return queue.ToArray();
    41.     }
    42.  
    43.     public int Count
    44.     {
    45.         get
    46.         {
    47.             return count;
    48.         }
    49.     }
    50. }
    But the graph just stops drawing after a while. I'm not able to understand why it doers so though. The points3 list is always populated with a certain number of points a all times. Could you please help me with figuring this out?
     
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I wouldn't recommend altering the line's rectTransform directly. Use VectorLine.drawTransform instead. Also I see that the code is framerate-dependent, since you're using Update without accounting for framerate variations, namely by using Time.deltaTime in some form. (Also you can just use Draw3DAuto() since Mathf.Infinity is the default.)

    --Eric
     
  36. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    having a bit of an issue where some VectorLines using Draw3DAuto disappear when one point of the line drops out of the camera's frustum, depending on the angle of the camera with how it is facing the lines.

    I'm using an orthographic camera, if I set the near clip to -100 (negative) it helps a bit but still happens. It is kind of weird... any ideas? Will try to get more info.
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If one or both points in a line segment go too far out of the camera view, it's disabled because otherwise it tends to draw incorrectly. If you break the line segment up into smaller segments that generally fixes it.

    --Eric
     
  38. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    Hi ,
    Is it possible answer post #483 about,
    how I can make my arrow bigger without changing my spline diameter?
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use a texture for the line material that makes the line look thinner; see the existing endcap demo examples.

    By the way, Vectrosity is part of the "tomorrow sale" on the asset store...get it 50% off for a week (until April 14)!

    --Eric
     
    shayan_315 likes this.
  40. dbaner

    dbaner

    Joined:
    Apr 7, 2015
    Posts:
    2
    Any tips on using SetColors efficiently. I'm drawing several 60 segment continuous lines which are animating and changing colour along their length every frame.

    The total Draw() time seems very reasonable at about 8% of a frame. But calling SetColors(Color[]) is taking an additional 21% of the frame which seems excessive in comparison. Calling SetColor on each range of segments individually is even slower. I'm thinking that creating a texture with the colour patterns I need may be quicker?

    I'm running on PC with Unity 5 / Vectrosity 4.1.1

    Thanks
     
  41. auroxi

    auroxi

    Joined:
    Dec 31, 2012
    Posts:
    85
    Would I be right in saying that this asset will allow me to draw a thin ring around one of my units in a radius of X efficiently? I'm using an orthographic/3d camera.

    I am basically using Physics.OverlapSphere on my GameObject and I'm wanting to visualise it for the player.

    Thanks
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That does seem excessive; it seems to me that SetColors doesn't really have to do much compared to Draw. I'll take a look at it.

    Yes, there's a MakeCircle function that makes it quite simple to do that.

    --Eric
     
  43. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    awesome, that did the trick, the line I made was very large. I made a simple function to help with the segments, not sure if the code is ideal but it works for my needs.

    In my specific case I was creating a big X, so now I do it like this:

    Vector3[] originPointsX = GenerateLine( new Vector3(-1000f,0f,0f), new Vector3(1000f,0f,0f), 2f, true );
    Vector3[] originPointsY = GenerateLine( new Vector3(0f,0f,-1000f), new Vector3(0f,0f,1000f), 2f, true );

    List<Vector3> originPoints = new List<Vector3>();//new Vector3[originPointsX.Length+originPointsY.Length];
    originPoints.AddRange( originPointsX );
    originPoints.AddRange( originPointsY );

    origin = new VectorLine("Origin",originPoints.ToArray(),null,2f,LineType.Discrete);

    Code (CSharp):
    1. Vector3[] GenerateLine( Vector3 from, Vector3 to, float segmentLength, bool discrete = false )
    2.     {
    3.         Vector3[] pts;
    4.        
    5.         float distance = Vector3.Distance(from,to);
    6.         int segmentCount = Mathf.RoundToInt(distance/segmentLength);
    7.        
    8.         //is even number (if a discrete line)
    9.         if ( discrete && segmentCount%2 == 1 )
    10.         {
    11.             segmentCount++;
    12.         }
    13.        
    14.         if ( segmentCount > 1 )
    15.         {
    16.             if ( discrete )
    17.             {
    18.                 segmentCount *= 2;
    19.                 Vector3 last = from;
    20.                 pts = new Vector3[segmentCount];
    21.                 pts[0] = from;
    22.                 for( int i=1; i<segmentCount/2; i++ )
    23.                 {
    24.                     float p = (float)i/(float)(segmentCount/2);
    25.                     Vector3 end = Vector3.Lerp( from, to, p );
    26.                     pts[i*2+0] = last;
    27.                     pts[i*2+1] = end;
    28.                     last = end;
    29.                 }
    30.             }
    31.             else
    32.             {
    33.                 pts = new Vector3[segmentCount];
    34.                 pts[0] = from;
    35.                 for( int i=1; i<segmentCount; i++ )
    36.                 {
    37.                     float p = (float)i/(float)segmentCount;
    38.                     Vector3 end = Vector3.Lerp( from, to, p );
    39.                     pts[i] = end;
    40.                 }
    41.             }
    42.             return pts;
    43.         }
    44.         else //line shorter than segmentLength
    45.         {
    46.             pts = new Vector3[2]{
    47.                 from,
    48.                 to
    49.             };
    50.         }
    51.         return pts;
    52.     }
     
  44. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    In a project, I made a list of Dashline with Dashline material. When I try to change
    color for my next lines , all of previously darwn list of dashline will be changed.
    how can I make an instance of dashline material for my List of Dashline?
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I guess you're using the same material for all the lines, so changing the color for the material changes it for everything using that material. I'd suggest using VectorLine colors instead of material colors (requires a shader that supports vertex colors).

    --Eric
     
    shayan_315 likes this.
  46. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    Hi again,
    I tried to reset my level with: Application.LoadLevel("Level1");
    Everythings became reload again without error . I tried to draw a new line, VectorCam and
    VectorLine are adding to my Hierarchy pannel every time I tried to draw a new line but I
    don't see any line.(I have checked vectorcam it is enable)
     
  47. auroxi

    auroxi

    Joined:
    Dec 31, 2012
    Posts:
    85
    Hi Eric,

    I purchased your asset and I've got it working so far as drawing a circle. I'd like it to slowly rotate the circle (which is made up of dashed lines) but I can't quite work it out. What do I need to change here:

    Code (CSharp):
    1.    
    2.     VectorLine myLine;
    3.     public float Radius = 5f;
    4.     public float LineWidth = 5f;
    5.     public bool drawLine = false;
    6.    
    7.     void Start () {
    8.         VectorManager.useDraw3D = true;
    9.     }
    10.  
    11.     void LateUpdate() {
    12.         if (drawLine == true && myLine == null) {
    13.             myLine = new VectorLine ("RadiusLine", new Vector3[300], null, LineWidth, LineType.Continuous);
    14.         }
    15.  
    16.         if (drawLine == true && myLine != null) {
    17.             transform.Rotate (0, Time.deltaTime * 5f, 0, Space.World);
    18.             myLine.MakeCircle (new Vector3 (this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z), Vector3.up, Radius);
    19.             myLine.material = Resources.Load ("Materials/Lines/DashLine") as Material;
    20.             myLine.Draw3DAuto ();
    21.         }
    22.  
    23.         if (drawLine == false) {
    24.             VectorLine.Destroy (ref myLine);
    25.         }
    26.     }
    27.  


    Thanks
     
    Last edited: Apr 8, 2015
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What version are you using? I've tested loading levels and things work as expected here.

    Probably animating the texture offset, rather than physically rotating the circle, would work best. By the way, Draw3DAuto should be called once. Since you're calling it every frame, you should use Draw3D instead. But in general I'd recommend moving as much out of Update as you can, and only call functions when they actually need to be called.

    --Eric
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As an update, it was because of Color to Color32 implicit conversions. So there will be an option to use Color32 arrays in addition to Color arrays, which results in a big speed increase for SetColors. Or maybe I'll just switch it over to Color32 instead of having both, unless there are any objections, since there doesn't seem to be any advantage to using Color compared to Color32.

    --Eric
     
  50. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    I am Using Vectorsity 3.1 with unity3d 4.3.1f but I have problem.