Search Unity

Vectrosity - Fast and Easy Line Drawing

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

  1. Deleted User

    Deleted User

    Guest

    Hello! How can i draw a line in front of gui?
     
  2. dbaner

    dbaner

    Joined:
    Apr 7, 2015
    Posts:
    2
    Either adding a Color32 version or converting the existing functions would be great and give my project a big speed increase.

    Thanks for looking into it.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use VectorLine.canvas to set the sorting layer of the vector canvas.

    --Eric
     
  4. iOSGamer

    iOSGamer

    Joined:
    Apr 6, 2015
    Posts:
    2
    Thanks Eric. I was able to create a moving line graph using Vectrosity. The graph that I am trying to draw is an area graph that looks like this.

    But I'm not able to figure out, how to make it happen. Is there any way to do this?
     

    Attached Files:

    • area.jpg
      area.jpg
      File size:
      20.4 KB
      Views:
      753
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, sorry, Vectrosity is only for lines; it can't do filled area shapes.

    --Eric
     
  6. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    Thanks for giving sample of multi threading resizing script.
    But I eager to know how I can read entire screen if I want take a screen capture of my VectorLines in an android
    project ? Is it Texure2D.ReadPixels good way to do that? what is your propose?
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As far as I know, ReadPixels works fine on Android. The docs say it doesn't work on Flash which would imply it works on all other platforms.

    --Eric
     
  8. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
    Im using 2d lines for performance reasons.
    Manualy changed canvas render to worldSpace for layering.

    How can i know that line is in camera viewport? So i will not redraw line when it is out of screen
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm afraid I don't really know; Vectrosity doesn't support that.

    --Eric
     
  10. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    Instead of drawing wireframe for a cube, can it draws outline only?
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, outlines are normally done with an image effect.

    --Eric
     
  12. Codemonger

    Codemonger

    Joined:
    Dec 12, 2013
    Posts:
    30
    In the profiler I am getting a Canvas.batchbuild running sucking up 3.5 m.s. every frame for something I've created in Vectrocity. In the previous version I had this outputting to a mesh without any issues. How can I alleviate this issue. If I turn off the canvas 3d renderer, the issue disappears, when I turn it back on then I get the extra canvas.batchbuild again. The Canvas3D is built by Vectrocity at runtime as well as the child gameobject - canvas renderer.

    I hope it is not rebuilding the mesh every single frame, this would not be required and nothing is changing ??

    Any ideas ?

    Thanks !
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Since Vectrosity 4 uses the Unity 4.6 canvas GUI system, it's subject to whatever rules govern that system. You can still use Vectrosity 3 if you want.

    --Eric
     
  14. Codemonger

    Codemonger

    Joined:
    Dec 12, 2013
    Posts:
    30
    Canvas.FillBatchMode is sucking up a ton of CPU ... I tested and if I disable the child of Canvas3D that vectrocity creates, I get NO CPU overhead, this 'pseudo solves the problem' ... but I'm concerned the grid I overlayed is not getting updated - as far as the shader is concerned. ie. It rendered to canvas3d once, and no longer renders given the normal etc. ; I need it to render though. I do not change the mesh at all btw or update any code, the object is pretty much static with exception of need to draw because position changes etc.

    Why is the UGUI object going bananas ? The mesh is using a shader that would have to redraw the lines. Maybe there is a setting when you create the child object that can be put in place that tells it not to go crazy (?)

    I would prefer not to revert back to 3.0 as I am using unity 5 pro and reverting backwards makes me cringe :)

    Thanks
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use Vectrosity 3 with Unity 5 without issues.

    --Eric
     
  16. Codemonger

    Codemonger

    Joined:
    Dec 12, 2013
    Posts:
    30
    I understand the easy solution of reverting back to 3, but on a move forward basis version 4 is the most current version and uses the UGUI Canvas, so I would like to understand why this is causing a problem -I may want to use new features of vectrocity 4. I'm guessing you are aware of the issue and don't have a resolution ? If this is the case, wouldn't it be beneficial to both of us if I provide more information ...

    • My current solution is that I disable the child object Vectrocity creates. After this it still renders on the canvas, but I can't move or resize it etc. which is fine with me - for this circumstance. Any changes in the material effects the canvas, so it is still rendering without need of the child object to be enabled.

    • Is it possible that you have a flag set for the child object (that holds the mesh) that is causing it to redraw every frame ? It seems it is rebuilding the batch (indices or vertices) every frame ... Could this be because of a Vectrocity setting, ie, change in resolution causes mesh to redraw . ?

    Just looking to narrow down why the object is continually redrawing on UGUI canvas every frame, this is not normal behavior to continually generate a batched mesh IMO. Maybe you have access to setting or know of setting on the UGUI child canvas renderer script.

    Thanks in advance!
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vectrosity only redraws lines when you specifically call Draw or Draw3D, or if you use Draw3DAuto, in which case that line is redrawn every frame. Otherwise there isn't any redrawing on my part. There are no meshes as such involved, at least in regards to the Mesh class; I use CanvasRenderer.SetVertices. There's an issue where deactivating a canvas object made with SetVertices doesn't cause it to actually deactivate/disappear, which I'd consider a bug, and I submitted a bug report about it. Because of that I had to implement a different way of deactivating lines instead of just using SetActive(false). Other than that I don't really know what goes on inside the Unity GUI code. The source code for that is available, though, if you want to take a look (I don't have the link offhand).

    --Eric
     
  18. Codemonger

    Codemonger

    Joined:
    Dec 12, 2013
    Posts:
    30
    Agreed about the bug and deactivating a canvas object.

    It would appear that Canvas.BuildBatch is being called every frame, which means that the dirty flag has been set on the Render Canvas of the child object of the 3D Canvas.

    I have attached the Canvas3D game object to a parent object that rotates every frame, this is what causes the BuildBatch to be called ... If I de-parent it, the BuildBatch is not called ... this seems awefully silly that the vertices have to be rebuilt every frame , the rotation would be no different than any normal parent --> child rotation, and not the other way around. Meaning the Canvas3D does not get a BuildBatch on rotation , but the child does (?) , even though the transform is the parent of both .. Strange ..

    Anyway found the cause - parent of canvas3D rotation triggers the child Canvas Renderer to re-build. Any idea's/thoughts of how to fix this ? in the meantime I will disable the child of Canvas3D which seems to strangely fix the problem although imo. this is part of a bigger bug

    Also is there a way to not have two canvas's , Canvas and Canvas3d created ?
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I think only Unity can fix that issue. The 3D canvas isn't created if Draw3D isn't used, but the standard canvas is always created. If it's not used it doesn't take any CPU.

    --Eric
     
  20. socoman3

    socoman3

    Joined:
    Jan 31, 2014
    Posts:
    19
    Hi Eric,

    I just purchased Vectrosity and run into some issues while testing it.
    I'm trying to create a VectorLine from an existing mesh. Below in the pic you can see that first I chose the segments with Line Maker, then I "generated a complete line" and pasted into a vector array. The code in C# is:

    private VectorLine myLine;
    void Start ()
    {
    Vector3[] hexagonGeom = {new Vector3 (-0.25f, 0.057f, 0.433f), ... };
    myLine = VectorLine.SetLine (Color.green, hexagonGeom);
    VectorManager.ObjectSetup (gameObject, myLine, Visibility.Dynamic, Brightness.None);
    }

    But the result is showing more edges than I want. Do you know what am I doing wrong?

    VectrocityIssue.png

    I'm using Unity 5, and have tried many times with Vectrosity 3 and 4, always with undesired results.

    I hope you can help me with this. Thanks!
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Can you paste the complete code?

    --Eric
     
  22. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
    How much smooth color hit the performance? Do i need to avoid using it?

    Say i got a line 25-35 segments. What will be better for performance using caps or smooth color? Im asking not about batching.

    Seems SetColors on smooth color line is sucking a lot of cpu time.
     
  23. socoman3

    socoman3

    Joined:
    Jan 31, 2014
    Posts:
    19
    Hi!

    The complete code of the script attached to the mesh gameObject is:

    using UnityEngine;
    using System.Collections;
    using Vectrosity;

    public class HexagonVector : MonoBehaviour {

    private VectorLine myLine;

    void Start ()
    {
    Vector3[] hexagonGeom = {
    new Vector3 (-0.25f, 0.057f, 0.433f),
    new Vector3 (-0.5f, 0.057f, 0f),
    new Vector3 (-0.25f, 0f, 0.433f),
    new Vector3 (-0.25f, 0.057f, 0.433f),
    new Vector3 (-0.5f, 0.057f, 0f),
    new Vector3 (-0.5f, 0f, 0f),
    new Vector3 (-0.5f, 0f, 0f),
    new Vector3 (-0.25f, 0f, 0.433f),
    new Vector3 (-0.5f, 0.057f, 0f),
    new Vector3 (-0.25f, 0.057f, -0.433f),
    new Vector3 (-0.25f, 0.057f, -0.433f),
    new Vector3 (-0.25f, 0f, -0.433f),
    new Vector3 (-0.25f, 0f, -0.433f),
    new Vector3 (-0.5f, 0f, 0f),
    new Vector3 (-0.25f, 0.057f, -0.433f),
    new Vector3 (0.25f, 0.057f, -0.433f),
    new Vector3 (0.25f, 0.057f, -0.433f),
    new Vector3 (0.25f, 0f, -0.433f),
    new Vector3 (0.25f, 0f, -0.433f),
    new Vector3 (-0.25f, 0f, -0.433f),
    new Vector3 (0.25f, 0.057f, -0.433f),
    new Vector3 (0.5f, 0.057f, 0f),
    new Vector3 (0.5f, 0.057f, 0f),
    new Vector3 (0.5f, 0f, 0f),
    new Vector3 (0.5f, 0f, 0f),
    new Vector3 (0.25f, 0f, -0.433f),
    new Vector3 (0.5f, 0.057f, 0f),
    new Vector3 (0.25f, 0.057f, 0.433f),
    new Vector3 (0.25f, 0.057f, 0.433f),
    new Vector3 (0.25f, 0f, 0.433f),
    new Vector3 (0.25f, 0f, 0.433f),
    new Vector3 (0.5f, 0f, 0f),
    new Vector3 (0.25f, 0.057f, 0.433f),
    new Vector3 (-0.25f, 0.057f, 0.433f),
    new Vector3 (-0.25f, 0f, 0.433f),
    new Vector3 (0.25f, 0f, 0.433f)
    };
    myLine = VectorLine.SetLine (Color.green, hexagonGeom);
    VectorManager.ObjectSetup (gameObject, myLine, Visibility.Dynamic, Brightness.None);
    }
    }

    I also tried applying the ObjectSetup to a different gameobject in scene but the results are the same.

    Thanks!
     
  24. socoman3

    socoman3

    Joined:
    Jan 31, 2014
    Posts:
    19
    I found some workarounds and now it kinda works.

    - Using "new VectorLine" instead of "VectorLine.SetLine"
    myLine = new VectorLine ("hex", hexagonGeom, null, 3f);​
    This solved the issue about the extra edges, but why...?

    - I also run into problems with the object lines rotation. If the object is already rotated in some angle, and then I create the segments with LineMaker, and update the code, most of the times it wont update the lines and will keep previous positions / rotations.
    I solved this using LineMaker after the object's transform is set to 0 (position, rotation, scale).

    - In order to make a prefab, I have to use the base gameObject of the mesh geometry as the ObjectSetup parameter. This has a transparent material, so I can keep the Mesh renderer activated (else won't work). If using a public gameObject as a parameter, then I'm not able to save the prefab (unless you do it on runtime which at the time I'm not that familiar with).

    Thanks
     
  25. Lovrenc

    Lovrenc

    Joined:
    Dec 13, 2012
    Posts:
    12
    Hello,

    I am using vectrosity for drawing some charts and I would like to place them onto my scrollable uGUI menu. I managed to get is scrolling by setting the parent of VectorLine.canvas.transform but since Vectrosity makes own canvas, I have a lot of trouble placing the chart to correct position. Can i set the canvas for vectrosity to use (i did not see any setters) or how should i tackle this?
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    SetLine only creates continuous lines. You need to create discrete lines for data from LineMaker to work correctly.

    LineMaker takes object rotation/scale/etc. into account when lines are created.

    I'm not really following this. If you take a look at the Simple3DObject demo scene, any of the cubes can be made into prefabs and it will work as expected.

    Probably using VectorLine.drawTransform to hook up lines to a transform, which is then moved (causing lines to move in sync), is the most convenient way.

    --Eric
     
  27. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As mentioned above, SetColors is somewhat slow because of Color -> Color32 implicit conversion. In the next version SetColors will use Color32 instead. If you want to fix this yourself for now, use the source and just change Color[] to Color32[] in the SetColors function. There shouldn't be any real difference between smoothColor or not.

    --Eric
     
  29. Joskym

    Joskym

    Joined:
    Oct 2, 2013
    Posts:
    39
    Hi, We just bought your plugin and it works great.
    But is it possible to return the GameObject on the Draw function ? (Or are there other ways to get the GameObject created from your plugin without doing a heavy Find ?)
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    VectorLine.rectTransform.gameObject.

    --Eric
     
  31. eezSZI

    eezSZI

    Joined:
    Nov 16, 2012
    Posts:
    121
    I've been trying to mask off an area within the canvas used by my VectorLines but it doesn't seem to work. Does vectrosity play nice with the Mask component with the new UI system? I'm using it the same way one would mask off any other Image.
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It doesn't seem like UI objects made with CanvasRenderer.SetVertices work with masks, which I would say is a bug in the UI system.

    --Eric
     
  33. eezSZI

    eezSZI

    Joined:
    Nov 16, 2012
    Posts:
    121
    Dang. Ok, thanks. I'll file a bug.

    Update: Case 689685
     
    Last edited: Apr 15, 2015
  34. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
    And also end cap+ smooth color bug?

    Any eta on next version?
     
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  36. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    Hi all! I was wondering if anyone could help me with a weird memory problem I´m having with Vectrosity + Aron´s A* Pathfinding (http://arongranberg.com/astar/).

    I am trying to display the pathfinding path through Vectrosity, however I'm getting some random memory problems I can´t understand. Here is a screenshot of it:


    I tried with both with Draw3D and the current Draw3DAuto to no avail. Here I post my current code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine.UI;
    5. using UnityEngine.EventSystems;
    6. using Pathfinding;
    7. using Vectrosity;
    8.  
    9. [RequireComponent(typeof(Seeker))]
    10. /// <summary>
    11. /// User interface manager.
    12. /// </summary>
    13. public class UIManager : MonoBehaviour {
    14.     //Here is a UIManager reference only this class can access
    15.     private static UIManager _instance;  
    16.     //This is the public reference that other classes will use
    17.     public static UIManager instance
    18.     {
    19.         get
    20.         {
    21.             //If _instance hasn't been set yet, we grab it from the scene!
    22.             //This will only happen the first time this reference is used.
    23.             if(_instance == null)
    24.                 _instance = GameObject.FindObjectOfType<UIManager>();
    25.             return _instance;
    26.         }
    27.     }
    28.     // UI Variables
    29.     private EventSystem _Event;
    30.  
    31.     // Pathfinding variable
    32.     [Range(0,2)]
    33.     public float pahtfindingRefreshRate = 0.25f;
    34.     private bool m_CanRefresh = true;
    35.     private Seeker m_Seeker;
    36.     private Vector3 oldOriginPos = Vector3.zero;
    37.     private Vector3 oldDestinationPos = Vector3.zero;
    38.  
    39.     // Pathfinding ui
    40.     public bool path3D = true;
    41.     public LayerMask TerrainLayer;
    42.     private bool showPath = false;
    43.     private VectorLine m_Line;
    44.     public List <Vector3> debugLine;
    45.     public Material lineMaterial;
    46.     [Range(0.01f,50.0f)]
    47.     public float lineWidth = 10.0f;
    48.  
    49.     // Physics
    50.     private Ray m_Ray;
    51.     private RaycastHit m_Hit;
    52.  
    53.     // Control variables
    54.     public bool inUI{get{return _Event.IsPointerOverGameObject();}}
    55.     /// <summary>
    56.     /// Start this instance.
    57.     /// </summary>
    58.     void Start()
    59.     {
    60.         // Get event manager
    61.         _Event = GameObject.Find("EventSystem").GetComponent<EventSystem>();
    62.         if (_Event == null)
    63.             Debug.LogError ("EventSystem wasn't found");
    64.  
    65.         // Get object components
    66.         m_Seeker = GetComponent<Seeker> ();
    67.  
    68.         // Initialize vectrosity variables
    69.         m_Line = new VectorLine("Pathfinding Route",  new List<Vector3>(), lineMaterial,lineWidth, LineType.Continuous,Joins.Fill);
    70.         m_Line.textureScale = 1.0f;
    71.     }
    72.  
    73.     /// <summary>
    74.     /// Send path request
    75.     /// </summary>
    76.     public void requestDisplayPathfinding(Vector3 origin,Vector3 destination)
    77.     {
    78.         // Check if we have
    79.         if (!m_CanRefresh)
    80.             return;
    81.  
    82.         // Check if there is need to update the pathfinding display
    83.         if (origin != oldOriginPos || destination != oldDestinationPos) {
    84.             m_Seeker.StartPath (origin, destination, DisplayPath);
    85.             oldOriginPos = origin;
    86.             oldDestinationPos = destination;
    87.             StopCoroutine("RefreshTimer");
    88.             StartCoroutine("RefreshTimer");
    89.             showPath = true;
    90.         }
    91.     }
    92.  
    93.     /// <summary>
    94.     /// Refresh Timer for the pathfinding display
    95.     /// </summary>
    96.     /// <returns>The timer.</returns>
    97.     IEnumerator RefreshTimer()
    98.     {
    99.         m_CanRefresh = false;
    100.         yield return new WaitForSeconds (pahtfindingRefreshRate);
    101.         m_CanRefresh = true;
    102.  
    103.     }
    104.  
    105.     /// <summary>
    106.     /// Hides the path.
    107.     /// </summary>
    108.     public void HidePath()
    109.     {
    110.         showPath = false;
    111.         m_Line.points3.Clear();
    112.     }
    113.  
    114.  
    115.     /// <summary>
    116.     /// Displays the requested path.
    117.     /// </summary>
    118.     public void DisplayPath(Path p)
    119.     {
    120.         if (!p.error && p != null) {
    121.             m_Line.points3.Clear();
    122.             // If the path is 2D, just add the same path we got from the pathfinder
    123.             if(!path3D)
    124.             {
    125.                 m_Line.points3.AddRange(p.vectorPath);
    126.             }
    127.             // Otherwise, raycast across the terrain surface to get the proper points heights
    128.             else
    129.             {
    130.                 foreach(Vector3 point in p.vectorPath)
    131.                 {
    132.                     m_Ray = new Ray(point + Vector3.up * 100.00f,-Vector3.up);
    133.                     if(Physics.Raycast(m_Ray,out m_Hit, Mathf.Infinity,TerrainLayer))
    134.                         m_Line.points3.Add(m_Hit.point);
    135.                     else
    136.                         m_Line.points3.Add(point);
    137.                 }
    138.             }
    139.             m_Line.Draw3DAuto();
    140.  
    141.             // Debug
    142.             debugLine = m_Line.points3;
    143.         }
    144.     }
    145. }
    146.  

    Any help is appreciated,
    Cheers
     

    Attached Files:

  37. omx-jonson

    omx-jonson

    Joined:
    Mar 23, 2014
    Posts:
    17
    Hi guys,

    I just got my copy of Vectrosity, it's fantastic, but I'm unable to achieve one thing.

    In my game I have very simple sprite shapes like this:

    And I would like to use Vectrosities LineMaker tool to create a line outline to my shape.
    However in order to use LineMaker, the object need to have MeshFilter component, which is impossible to add while using SpriteRenderer.

    What's the best way to create 2D objects from Sprite (how to generate Mesh from Sprite) to have LineMaker be able to easily outline my 2D shapes?

    TL;DR:
    How to use LineMaker with Sprites?

    Hope you can help me out,
    Bests
    Mike
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    LineMaker requires an actual mesh to be usable, so it's not possible to use a SpriteRenderer, sorry.

    @neroziros: do you have a script without dependencies that shows this? Otherwise please send me a project via PM.

    --Eric
     
  39. Pete_1061

    Pete_1061

    Joined:
    Apr 17, 2015
    Posts:
    16
    Is Vectrosity able to cast shadows? Because I can't get it to cast shadows.
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Canvas objects can't cast shadows as far as I know.

    --Eric
     
  41. Mucks

    Mucks

    Joined:
    Mar 19, 2015
    Posts:
    4
    Hello. I recently bought Vectrosity to help me out with a laser I have within the game I am working on. I did this because the built in LineRenderer wasn't keeping the lines it was drawing at a consistent thickness due to a well known rendering error.

    So essentially what I am trying to do is use RaycastHit points to draw a continuous laser which reflects off of certain objects.

    All I need to do is incorporate the actual visible lines since my Raycasts are working fine, so all I need to do is input the Vector3 positions into Vectrosity to draw them for me.

    However, I am running into some issues when trying to use this code from the documentation.
    Code (JavaScript):
    1. var myLine = VectorLine("MyLine", new Vector2[0], null, 2.0);! ! // JS
    2. var myLine = VectorLine("MyLine", new List.<Vector2>(), null, 2.0);
    Initially I tried to use the first line but I got a "The type 'Vectrosity.VectorLine' does not have a visible constructor that matches the argument list" for the array.

    Next I tried to use the list but that came up with a similar error. It seems if I copy and paste exactly what I need from the documentation it still won't work. Has there been a recent change which outdates the documentation in regard to what I am trying to do?

    And if there is a simpler way I would love to hear suggestions on how I can render the laser within my game. Since the hit points of each laser reflection are constantly changing in the Update function, I need to create the laser once and simply change the location of each of its points. Either that or I can simply create endless lasers with very short lifespans.

    I'm still trying to wrap my head around Vectrosity and I would like it very much if someone could point me in the right direction for what I want to do. Thanks.
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sounds maybe like you're mixing Vectrosity 4 with the Vectrosity 3 docs, or vice versa. I copy/pasted the code you posted and it works as expected (version 4.1.3).

    --Eric
     
  43. Mucks

    Mucks

    Joined:
    Mar 19, 2015
    Posts:
    4
    I am running Unity 5. Is that a problem?
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, Vectrosity works fine with Unity 5. Again, make sure you have imported the correct version of Vectrosity to go with the docs you're reading (latest version is 4.1.3). They're not interchangeable; Vectrosity 3 for example can't use Lists to create VectorLines.

    --Eric
     
  45. Mucks

    Mucks

    Joined:
    Mar 19, 2015
    Posts:
    4
    I believe I did have an importation problem. I think I might have accidentally imported both versions of the plugin and by default the initial import line in my script was using the wrong version.

    I've spent a bit of time setting up my lines and I am able to achieve what I want with VectorLine.SetLine.

    However, I want to be able to slightly increase the width of these lines. Is this possible or will I have to delve into the more advanced line techniques for this?
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can set the width of the lines either when declaring them, or by using VectorLine.lineWidth afterward.

    --Eric
     
  47. Mucks

    Mucks

    Joined:
    Mar 19, 2015
    Posts:
    4
    I think I'm starting to get the hang of Vectrosity step by step.

    Thanks a lot for all your help, Eric. You've been exceptionally beneficial.
     
  48. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    I am working with vectrosity 3.1.
    Now, I have understood when I draw a line with Arrow or any kind of cap.
    After using Application.loadlevel("Sample"); line cannot be drawn again and I encouter with :
    Code (CSharp):
    1. VectorLine: end cap "Arrow" has already been set up
    2. UnityEngine.Debug:LogError(Object)
    3. Vectrosity.VectorLine:LogError(String) (at Assets/Plugins/VectrosityScripts/VectorLine.cs:1065)
    4. Vectrosity.VectorLine:SetEndCap(String, EndCap, Material, Single, Texture2D[]) (at Assets/Plugins/VectrosityScripts/VectorLine.cs:3863)
    5. Vectrosity.VectorLine:SetEndCap(String, EndCap, Material, Texture2D[]) (at Assets/Plugins/VectrosityScripts/VectorLine.cs:3851)
    6. RightCap:Start() (at Assets/RightCap.cs:33)
    7.  
    Error how can solve this error?
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Don't re-run code that sets up the "Arrow" end cap. It should only ever run once.

    --Eric
     
  50. shayan_315

    shayan_315

    Joined:
    Sep 24, 2013
    Posts:
    28
    I don't re-run code that sets up the "Arrow" end cap.
    This is my code:
    Code (CSharp):
    1. void Start ()
    2.     {
    3.         Vector2[] points = new Vector2[]{new Vector2(.4f, .4f),new Vector2(1, 1)};
    4.         arrowLine = new VectorLine("ArrowLine", points, lineMaterial, 20f);
    5.  
    6.         var line3 = new VectorLine("Rounded", points, lineMaterial, 2f);
    7.         line3.useViewportCoords = true;
    8.  
    9.         VectorLine.SetEndCap("Arrow", EndCap.Front, lineMaterial, frontTex);
    10.         line3.endCap = "Arrow";
    11.  
    12.         line3.Draw();
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.         restartMen();
    18.     }
    19.     void restartMen(){
    20.         Vector3 _TouchposeMM = Camera.main.ScreenToWorldPoint (Input.mousePosition);
    21.         RaycastHit2D _hittedSetMM = Physics2D.Raycast (_TouchposeMM,Vector2.zero);
    22.        
    23.         if (_hittedSetMM != null && _hittedSetMM.collider != null && _hittedSetMM.collider.name == "AA")
    24.         {
    25.             Application.LoadLevel("DrawingSelectLine");
    26.         }
    27.  
    28.     }