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. Mike-Le-Watt

    Mike-Le-Watt

    Joined:
    Mar 28, 2016
    Posts:
    6
    Thanks Eric, will check it out.
     
  2. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    Is there any way to make the width of lines not scale when the camera zooms? I purchased this and legit, this is my biggest issue because I have a game where the screen zooms quite often and by large amounts.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The line width doesn't change when the camera zooms; that's the idea; e.g. if you set the width at 2, then the line will always be 2 pixels. Make sure you update the line when the camera changes.

    --Eric
     
  4. Mike-Le-Watt

    Mike-Le-Watt

    Joined:
    Mar 28, 2016
    Posts:
    6
    Eric, forgive me if I'm being stupid, I'm still a C#/Unity noob. However I'm really stumped. The game is 2D. The line colliders are not interacting with the 2D box colliders for my shape objects.

    Here's a Game view, I want the vector line to collide and trigger when you draw it over one of the shapes.



    Here's the same in Scene view:



    As you can see the line collider is tiny and really far from the shape colliders. I have no idea how to scale/adjust this so it's in sync. Again, sorry if my question is stupid.
     
  5. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    Oh I see, yeah that's the issue I'm encountering actually is that the lines perhaps don't scale. Sorry for misspeaking, but also thanks for the quick response!

    Is it not possible to correctly scale the lines to camera's size as though they were actual world objects? Because my camera zooms in and out a lot and I wanted to use vectrosity for lasers and in-world effects, I need their widths to scale correctly with the zoom amount.

    Sorry again for the mistake! This is my real question!
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    As mentioned, the scene view has nothing to do with the game view when it comes to the UI. UI objects on canvases use 1 pixel = 1 unit, so even though you can see a canvas in the scene view, it's not related to the game world. (There has been a suggestion that Unity use a separate view for the UI instead of essentially hacking it into the scene view.) You should use world space for your game objects; don't try to match them with the UI in the scene view (especially since that seems likely to break when changing screen size/resolution).

    No, sorry, Vectrosity isn't really appropriate for that. Unity has a built-in line renderer that behaves like a world object.

    --Eric
     
  7. Mike-Le-Watt

    Mike-Le-Watt

    Joined:
    Mar 28, 2016
    Posts:
    6
    I've kind of figured it out, the line collider now properly collides with the other object colliders.





    My issue now is that line drawing is perfect in the editor, however if I 'Maximise On Play', line drawing is offset.

     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Calculate line coords based on screen resolution, rather than hard-coding them.

    --Eric
     
  9. Mike-Le-Watt

    Mike-Le-Watt

    Joined:
    Mar 28, 2016
    Posts:
    6
    I get the coordinates from a raycast2D. They work in various sized windows, unless I Maximise on Play.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You have it set to "free aspect"; maybe try a specific aspect ratio, though there's nothing special about maximize on play that would break Vectrosity. It's just another window size, and works with everything I've done.

    --Eric
     
  11. Mike-Le-Watt

    Mike-Le-Watt

    Joined:
    Mar 28, 2016
    Posts:
    6
    It's strange, line canvas is set to Screen Overlay. The player sets the coordinates of the vector line by clicking on the white tiles (10x10 grid). This works in free aspect window, as well as full screen under some resolutions. In larger resolutions it's completely broken and not aligned.
     
  12. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    Any suggestions on how to go about getting collision to work on picking within the bounds of a polygon made by vectrosity? And also to fill the centre of the shape?
     
  13. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    Another question with an issue I've encountered: Is there a quick way available to copy a line to another variable? I've not found anything in the documentation regarding it.
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I can only suggest examining your code to see where the issue might be. Vectrosity itself doesn't have any resolution dependencies.

    Vectrosity is for line-drawing only; it doesn't fill shapes. I didn't understand the first question.

    Create a new line with the same parameters.

    --Eric
     
  15. MathBeam

    MathBeam

    Joined:
    Nov 5, 2014
    Posts:
    1
    Hi Eric,

    I'm thinking about a 2D world map, as seen below. I'm generating this through code, do you think Vectrosity is a good method to achieve this? I like that static lines don't have to be constantly redrawn, and that I wouldn't have to many individual sprites or worry about meshes.
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It would work for the outlines, but you'd still need something to fill the interior, so I'm not sure you'd really end up saving anything.

    --Eric
     
  17. son1cman

    son1cman

    Joined:
    Jan 2, 2015
    Posts:
    15
    how it will perform with 100 - 500 lines each lets say 10 - 70 segments?
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That depends on the hardware, but if you're just using static lines, it's likely to be negligible.

    --Eric
     
  19. son1cman

    son1cman

    Joined:
    Jan 2, 2015
    Posts:
    15
    cool!! they arent static(most of the time) all lines are made of vertex right? its for an averge pc.
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Lines aren't static if they need to be updated, so it depends.

    --Eric
     
  21. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    i am trying to draw a smooth spline by using _line.MakeSpline(_splinePoints ) , however the line i am getting has hard turns and not a proper catmull rom style smooth spline.. what am i doing wrong?
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I can't tell without seeing code, but at a guess you're not using enough points in the line.

    --Eric
     
  23. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    Code (CSharp):
    1.  
    2.     void DrawLine()
    3.     {
    4.         _line = new VectorLine(_lineName, _linePoints, _lineWidth,LineType.Continuous,Joins.Weld);
    5.  
    6.         //_line.material = _lineMaterial;
    7.         _line.texture = _lineTexture;
    8.         _line.continuousTexture = true;
    9.         _line.smoothWidth = _lineSmoothWidth;
    10.         _line.SetWidths(_lineWidths);
    11.  
    12.         _line.MakeSpline(_splinePoints.ToArray());
    13.         _line.Draw3D();
    14.     }


    These are _linePoints and _splinePoints that i am feeding via inspector.

    The result is like this , i need smooth spline. I am not sure if i misinterpreted that feeding fixed set points will be interpolated by Vectrosity to generate Catmul Rom Curve and rendered accordingly with provided VectorLine settings.


    Also , whats the correlation bewteen the _linePoints that i am using to create the VectorLine Object and the _splinePoints that i am feeding to MakeSpline method ? i have gone through entire documentation twice but the concept isn't clear to me.
     
    Last edited: Apr 1, 2016
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You need to add far more points in the line. You only have 4; it can't make anything other than a few segments with that.

    --Eric
     
  25. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    Any minimum value? what should i aim for ?
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Whatever looks good; if the line is updated a lot, then ideally try to use as few as you can get away with.

    --Eric
     
  27. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    Thanx! i have got it working now. :)
     
  28. MakeGames2020

    MakeGames2020

    Joined:
    Nov 14, 2014
    Posts:
    14
    Hi just recently purchased Vectrosity and im playing around with line textures. Just wondering what I need to do to get glowing lines like the ones you have in one of your web demos.
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    All the demos are included, so you can get the texture from there.

    --Eric
     
  30. cl0sed

    cl0sed

    Joined:
    Mar 9, 2016
    Posts:
    1
    Hello,

    Will it handle drawing 100k+ static lines with variable lenght and color (<20) at runtime?
    Can i pool created lines to efficiently show-hide them later at any moment?
     
  31. Rikrok

    Rikrok

    Joined:
    Apr 11, 2013
    Posts:
    50
    I'm using the VectorManager on my objects. Is there any way to have the lines work with an animated skinned mesh?
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It depends on the hardware, but that should be fine in most cases as long as the lines were not actually separate objects.

    They would have to be pooled to get acceptable performance (100K draw calls is a no-go). So hide/showing would be complicated somewhat, but you could do things like setting appropriate line segments to transparent instead of actually disabling them.

    You can use Unity's BakeMesh function, but it's not particularly fast, so it may not be feasible.

    --Eric
     
  33. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    Hi Eric!

    How can i draw VectorLine on top of a 2D Sprite? I am using Draw3D() since i need the lines to be inside the scene.
    drawDepth is for Canvas Line so thats of no use and setting Layer has no effect.
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Setting a standard layer wouldn't have any effect, unless you were using multiple cameras with appropriate culling masks. Typically you'd use sorting layers and/or order in layer values.

    --Eric
     
  35. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    84
    Can i set sortingOrder and sortingLayer for Lines?
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, Renderer.sortingLayerName and Renderer.sortingOrder.

    --Eric
     
  37. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hi Eric - using Vectrocity to make a small painting app. I've adapted your drawing code to c# and it seems to be working fine on PC, but upon sending the build to my Nexus 7 Android Tablet, I can't seem to get lines drawing / displaying (while it works for your original DrawLinesTouch.js). Any chance you could take a look at some of this code, perhaps see where I'm going wrong?

    EDIT: Please disregard, fixed.

    Appreciate your time, Vectrocity seems like an amazing tool!
    --Rev
     
    Last edited: Apr 5, 2016
  38. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    Hi, not sure where I'm going wrong. I'm sure this is a simply fix and that someone has already asked something similar but I can't seem to find anything (the curse of a 30 page thread).

    My lines don't seem to be drawn fully when I rotate my camera in 3D space. Camera is set to orthographic, the lines are drawn using Draw3DAuto when they are created. I am using the "thinline" texture from the samples.

    Any ideas?

    Thanks.
     

    Attached Files:

  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If necessary, use SetCamera3D to set the appropriate camera.

    --Eric
     
  40. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Sorry to drop in here again, but currently having trouble getting endcaps and colour changes to work on my Nexus 7, using either the sample DrawLinesTouch.js or my own script.

    Code (CSharp):
    1. #pragma strict
    2. import Vectrosity;
    3. import System.Collections.Generic;
    4.  
    5. var lineTex : Texture;
    6. var maxPoints = 5000;
    7. var lineWidth = 4.0;
    8. var minPixelMove = 5;    // Must move at least this many pixels per sample for a new segment to be recorded
    9. var useEndCap = false;
    10. var capLineTex : Texture;
    11. var capTex : Texture;
    12. var capLineWidth = 20.0;
    13.  
    14. var lineColour : Color= Color.red;
    15.  
    16. private var line : VectorLine;
    17. private var previousPosition : Vector2;
    18. private var sqrMinPixelMove : int;
    19. private var canDraw = false;
    20. private var touch : Touch;
    21.  
    22. function Start () {
    23.     if (useEndCap) {
    24.         VectorLine.SetEndCap ("RoundCap", EndCap.Mirror, capLineTex, capTex);
    25.         var tex = capLineTex;
    26.         var useLineWidth = capLineWidth;
    27.     }
    28.     else {
    29.         tex = lineTex;
    30.         useLineWidth = lineWidth;
    31.     }
    32.    
    33.     line = new VectorLine("DrawnLine", new List.<Vector2>(), tex, useLineWidth, LineType.Continuous, Joins.Weld);
    34.     line.endPointsUpdate = 1;    // Optimization for updating only the last point of the line, and the rest is not re-computed
    35.     if (useEndCap) {
    36.         line.endCap = "RoundCap";
    37.     }
    38.     // Used for .sqrMagnitude, which is faster than .magnitude
    39.     sqrMinPixelMove = minPixelMove*minPixelMove;
    40. }
    41.  
    42. function Update () {
    43.     if (Input.touchCount > 0) {
    44.         touch = Input.GetTouch(0);
    45.         if (touch.phase == TouchPhase.Began) {
    46.             line.points2.Clear();
    47.             line.Draw();
    48.             previousPosition = touch.position;
    49.             line.points2.Add (touch.position);
    50.             canDraw = true;
    51.         }
    52.         else if (touch.phase == TouchPhase.Moved && (touch.position - previousPosition).sqrMagnitude > sqrMinPixelMove && canDraw) {
    53.             previousPosition = touch.position;
    54.             line.points2.Add (touch.position);
    55.             // line.SetColor(lineColour); // <== Attempt to change colour once!
    56.             line.color = lineColour; // <== Attempt to change colour a second time.
    57.             if (line.points2.Count >= maxPoints) {
    58.                 canDraw = false;
    59.             }
    60.             line.Draw();
    61.         }
    62.     }
    The only change I've made here to the original DrawLinesTouch script was to add a Color variable 'lineColour'. I've tried to change the colour of the line in two different ways towards the end of the Update function. The script also fails to add endcaps to the lines - leaving me with a thick, square -end line when compiled and sent to my Nexus 7 Android Tablet.

    Any clues on what's happening here? I'm looking forward to fixing my own script when I've got the sample script working...!

    --Rev
     
  41. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    I just discovered it is because I am rotating the rect transform of the shapes. Is there any way to get the line to behave after its rect transform has been rotated?
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You should be able to set the line color once in the Start function, rather than Update. Also make sure the color in the inspector has the correct alpha.

    No; the best thing to do would be to avoid touching the rotation of the lines directly, and instead use drawTransform (typically with an empty transform), where you rotate that transform.

    --Eric
     
  43. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hi Eric! Thanks for the response. I've checked the colour in the inspector has the correct alpha - it's at full, 255. What's more, the colour in the inspector (before the project is built for the tablet) is red - on the tablet, it's coming out as black.

    Just to restate the situation:

    vectrosityProblems.png
    I'm hoping to effectively replicate the behavior on PC on the tablet, as I'm making a very small painting application.

    Most of my code is in two functions, called on Input.GetMouseButtonDown(0) and Input.GetMouseButton(0) or, on the tablet, Input.touchCount > 0 and touch.phase == TouchPhase.began.

    Code (CSharp):
    1. public void StartDrawingLine()
    2.     {   // Creating the new line and adding it to the generic list
    3.         mobileAlert.text = "Starting to draw a line";
    4.         lines.Add(new VectorLine("DrawnLine" + currentLineNumber, new List<Vector2>(), lineTex, lineWidth, LineType.Continuous, Joins.Fill));
    5.         currentLineNumber++;                                    
    6.         lines[lines.Count - 1].endPointsUpdate = 1;            
    7.         lines[lines.Count - 1].endCap = "RoundCap";            
    8.         if(Application.isEditor) lines[lines.Count - 1].points2.Add(newMousePos);        
    9.         if(Application.isMobilePlatform) lines[lines.Count - 1].points2.Add(touch.position);
    10.         // lines[lines.Count - 1].SetColor(lineColour);
    11.         lines[lines.Count - 1].Draw();                          
    12.         if(Application.isEditor) previousPosition = Input.mousePosition;    
    13.         if(Application.isMobilePlatform) previousPosition = touch.position;
    14.         canDraw = true;                                        
    15.     }
    16.  
    17.     public void ContinueToDrawLine()
    18.     {  
    19.        
    20.         if (Application.isEditor) previousPosition = Input.mousePosition;    
    21.         if (Application.isMobilePlatform) previousPosition = touch.position;
    22.         if (Application.isEditor) lines[lines.Count - 1].points2.Add(newMousePos);        
    23.         if (Application.isMobilePlatform) lines[lines.Count - 1].points2.Add(touch.position);
    24.         lines[lines.Count - 1].color = lineColour;
    25.         lines[lines.Count - 1].Draw();                          
    26.         int pointCount = lines[lines.Count - 1].points2.Count;  
    27.         if (pointCount >= maxPoints)                            
    28.         {
    29.             canDraw = false;                                    // Prevent draw
    30.         }
    31.     }
    Any help would be appreciated, on tight deadline and have high hopes for Vectrocity. =)

    --Rev
     
  44. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    Hi Eric,

    Thanks for the quick reply. Just to make sure I'm following you;

    I was doing the following, now I am doing the same thing except with "drawTransform".
    Code (CSharp):
    1.  
    2.         VLine.rectTransform.position = Vector3.zero;
    3.         VLine.rectTransform.rotation = Quaternion.identity;
    4.         VLine.rectTransform.RotateAround(DatumPoint, Vector3.up, Rotation);
    5.  
    The issue is still occurring but it seems to be much less frequent. Once I isolate a particular shape it is failing on I will be able to learn more. If I can't fix it alone I may message again!

    Thanks for the help.
     
  45. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're getting different behavior on a device as opposed to the editor, and the settings for textures etc. are the same, it sounds like a Unity bug. Probably with the shader, so you could try using a different material with a different shader.

    I don't think it's actually possible for that to happen if DrawTransform is being used correctly, so I'd suggest double-checking that first.

    --Eric
     
  46. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hi Eric. Okay, so I've tested all the currently available shaders included in Unity 5 with Vectrocity - results in a doc here (https://docs.google.com/document/d/1T5h_bS7mhFS628yk4lO6XOQpun_ScEPSmZRjV02ODMY/edit?usp=sharing), for those interested. I made Vectrocity draw the lines with a specific material, then swapped through all the shaders in an unlit environment.

    Of the shaders that worked somewhat on the PC, only 9 didn't have some weird artifacts. Only one of the nine would give me colours when built as an .apk for my Android Nexus 7, the GUI/Text Shader - but this still doesn't display the caps correctly.

    (By the way, as I suspect you suspected, the caps are being drawn on the lines, they're just not displaying correctly - they show up as blocks at the ends of the lines without the alpha roundness - hence the problem is a shader issue).

    I'll be submitting this as a bug to Unity shortly - have you any advice on the information they'll require for the report? I don't suppose you know if they're likely to get back to me fairly quick - I've a serious deadline and I'm thinking of adapting Aron Granberg's Unitypaint if this is going to take a long time (shame, 'cause it doesn't hold a candle to Vectrosity).

    --RoB
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They will want, ideally, a simple repro project that shows the bug in as focused a manner as possible. (You can include Vectrosity when submitting bug reports to Unity, since they aren't distributed elsewhere.) Like making a basic scene that just draws a line, and show how it looks in the editor, and how it looks when making an Android build, and mention how it should look the same for both. How fast it's fixed varies, but reports that are easy to verify tend to be fixed quickly, assuming the fix is relatively easy to implement.

    --Eric
     
  48. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    Y̶o̶u̶'̶r̶e̶ ̶r̶i̶g̶h̶t̶,̶ ̶I̶ ̶t̶h̶i̶n̶k̶.̶ ̶T̶h̶e̶r̶e̶ ̶w̶a̶s̶ ̶a̶ ̶s̶e̶c̶t̶i̶o̶n̶ ̶o̶f̶ ̶m̶y̶ ̶c̶o̶d̶e̶ ̶t̶h̶a̶t̶ ̶s̶t̶i̶l̶l̶ ̶h̶a̶d̶ ̶u̶s̶e̶ ̶o̶f̶ ̶r̶e̶c̶t̶T̶r̶a̶n̶s̶f̶o̶r̶m̶.̶ ̶I̶'̶v̶e̶ ̶c̶h̶a̶n̶g̶e̶d̶ ̶t̶h̶a̶t̶ ̶n̶o̶w̶.̶ ̶I̶'̶v̶e̶ ̶n̶o̶t̶ ̶s̶e̶e̶n̶ ̶t̶h̶e̶ ̶i̶s̶s̶u̶e̶ ̶s̶i̶n̶c̶e̶ ̶t̶h̶e̶ ̶f̶i̶r̶s̶t̶ ̶c̶h̶a̶n̶g̶e̶ ̶e̶x̶c̶e̶p̶t̶ ̶o̶n̶ ̶a̶ ̶s̶i̶n̶g̶l̶e̶ ̶s̶h̶a̶p̶e̶ ̶b̶u̶t̶ ̶I̶ ̶f̶o̶o̶l̶i̶s̶h̶l̶y̶ ̶d̶i̶d̶n̶'̶t̶ ̶d̶o̶c̶u̶m̶e̶n̶t̶ ̶t̶h̶e̶ ̶s̶h̶a̶p̶e̶s̶ ̶b̶u̶i̶l̶d̶ ̶p̶o̶i̶n̶t̶s̶ ̶s̶o̶ ̶I̶ ̶c̶a̶n̶'̶t̶ ̶r̶e̶-̶t̶e̶s̶t̶.̶

    E̶d̶i̶t̶:̶ ̶A̶n̶y̶ ̶i̶d̶e̶a̶ ̶w̶h̶y̶ ̶d̶r̶a̶w̶T̶r̶a̶n̶s̶f̶o̶r̶m̶ ̶w̶o̶u̶l̶d̶ ̶s̶u̶d̶d̶e̶n̶l̶y̶ ̶s̶t̶a̶r̶t̶ ̶b̶e̶i̶n̶g̶ ̶n̶u̶l̶l̶?̶

    Further Edit: So. It turns out that drawTransform was always null and the only reason my rotation was working at all was due to the rectTransform rotate. Any ideas why drawTransform is null? I've tried setting it to rectTransform when it is null but that doesn't fix the issue.

    PS. Just to confirm something; if I want to parent the lines to something I need to use rectTransform.SetParent, correct?
     
    Last edited: Apr 7, 2016
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If drawTransform is null, I can only assume it's because it wasn't set to an object's transform. Have a look at some of the demos where drawTransform is used, such as the Text demo. In general I wouldn't recommend using SetParent, since moving lines directly tends to break Vectrosity, but yes that's how it's done. If you use SetParent with an object that doesn't move or rotate, it would be OK.

    --Eric
     
  50. Questioning

    Questioning

    Joined:
    May 17, 2015
    Posts:
    17
    The SetParent may be the key then, as I set all of the lines to parent under their own game object, then I rotate their rectTransform. I'll take a look at the demos over the weekend and see what I find. As I think I mentioned I set drawTransform to rectTransform but that ended up re-introducing the issue.

    Is there any way to set them to another game object? Purely for housekeeping purposes.

    Edit: Pretty sure I fixed the rotation issue by adding a new game object for each shape to hold the rotation.
     
    Last edited: Apr 8, 2016