A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by Eric5h5, Sep 26, 2014.
Are you using Draw or Draw3D?
I use Draw3DAuto.
If I use VectorManager.ObjectSetup for the cube edges, it looks much more consistant and doesnt jump back and forth, but always renders that longer orange side on top.
Shall I use Vectormanager for all lines in this case?
Here is the current setup with VectorManager applied to cube edges only.
Are you using a shader that writes to the depth buffer? The default line material doesn't.
OMG, thank you!
I've missed to check that sorry!
Now it works like charm!
Thank you for your excellent work and support!
Hey, I'm having issues with end cap textures and colliders. They work fine with no end caps, but if I add a semi-circle end cap, I end up getting a bunch of stray points at (0,0,0). It would be good if I could disable colliders for end caps as I have no need for them anyway.
Also it would be even better if I could just create an edge collider of the line itself, rather than tracing the entire texture. I'm using bunch of thin lines so I have no real need for that much fidelity.
Many thanks, this is probably my favourite Unity asset
Hi, I'm not seeing this behavior...I tried this code (and some variations):
VectorLine.SetEndCap ("rounded", EndCap.Mirror, lineTex, frontTex);
var points = new List.<Vector3>([Vector3(1, 1), Vector3(2, 2), Vector3(3, 1)]);
var testLine = new VectorLine("Test", points, 20.0, LineType.Continuous, Joins.Weld);
testLine.endCap = "rounded";
testLine.collider = true;
Which gets this:
The edge collider only uses the line coords anyway, and can't trace the texture (I expect that would be quite slow, plus I would have had to code it ):
In Line Maker could you make it/add an option so that if a mesh has "Keep Quads" enabled on its import settings the "Connect all points" button only connects the quad edges as opposed to all the triangles?
It looks like that would be feasible.
The workaround did work! Thank you!
thank you for developing such great asset.
I made a game with vectrosity, and I want to give link, if it is OK.
This line will not resize the points array (using 2d points).
if it's called twice it resizes the points succefuly.
I'd recommend using an ObservableCollection for points and updating the point count when points are added if you wish to have a seperate field to keep track of points count.
I'd also recommend that when using the MakeRect() function, if the point size is smaller than the required amount resize the list internally.
It will work if you don't use Clear (which isn't necessary since the values get overwritten anyway). Good point about MakeRect; it originated back when Vectrosity was using an array for the points rather than a List.
What I try to do is
- Changing the width of some Vectrosity lines
- Take a sample of the screen by rendering (on a separate camera) to a rendertexture.
- changing line width back again.
But I can't get it to work. The camera will grab the screen with the old linewidths. Only if I put it in a coroutine and yield a frame in between changing the line widths and grabbing the rendertexture it works. But then the user sees it which is not my intention.
Any idea on how to solve this?
Line meshes are updated once per frame, so I'd suggest having another separate line on a layer only the rendertexture camera can see.
(Probably something stupidly simple I'm missing...)
Essentially I want to take the 3D grid example but have a whole lot more points on the lines for mesh distortion.
So yes I could loop through and create all the points... but what I would like to do is use VectorLine.MakeSpline a bunch of times horizontal, a bunch of times vertical and then that's my mesh. I'll loop through the verts and voila.
Problem is it's creating a separate object for each Spline object. Is there any way to merge them together in to one nice object? Or am I overthinking the problem?
MakeSpline has the option to pass in the number of segments and an index, so you can make any number of splines in a single VectorLine. However I'd just loop through and add the points; that's not any more difficult than using MakeSpline for this and would be faster.
Do you think you could implement the connect all quads into the next version?
Yep, that's the plan.
Hello, Maybe this is a silly question, but does vectrosity support drawing in the canvas of uGUI? I know it supports 3D and 2D, but I'm looking to draw a dotted curve in the HUD of my app and was wondering if this plugin can do it.
The 2D drawing only works in a canvas, in fact. (3D lines are meshes in world space.)
If I want to mix together elements from uGUI with a curve, can that be done? for example I have a couple of orange round square uGUI buttons, and then I draw a curve, but want some buttons to be on top of the curve and others to be under it. Is there a way to do that? (sorry if it's a very basic question, but I just got your asset Today). Thanks for any help.
Yes, you can use Transform.SetSiblingIndex to make the buttons draw on top. (Also VectorLine.drawDepth for setting the sibling index of lines.)
I have an issue with line.smoothWidth not working with a 3D line where I manually set the lineWidth while the line is being created (by drawing in 3D).
I am using Unity 5.4.3 and Vectrosity 5.3. Could this be caused because of using Unity 5.4.3?
Here's what it looks like with line.smoothWidth = true
Hard to tell from the screenshots, but it looks like your line points aren't continuous. For example, something like this would work:
(100, 100), (150, 100), (200, 150)
Whereas it looks like you might have something like
(100, 100), (150, 100), (150, 100), (200, 150)
I don't think that is the case because I am drawing the line using a mouse based on the DrawLinesMouse.js example. I am drawing a new point (line) when the mouse position moves a certain distance, so the new point should always be different.
Here is what the document says should happen:
And here is the section of the code where I am using the smoothWidth and am changing the line:
I am using this in 3D and will use this for creating a simple drawing app in VR with a motion controller. I am also running into the problem where the Z-depth of the drawing does not affect the size of the line (in the camera) because Vectrosity automatically relocates the line to match the camera's view frustum to make sure the 'width' of the line in pixels always matches the camera when drawn... this is not the desired behavior when drawing in 3D with a motion controller in VR, is there also a way to change this functionality in Vectrosity so that the further away you draw the line from the camera, the smaller the line appears? (based on camera frustum depth).
Here is more code I am using incase the above is not enough. This the entire Update() code.
var newPoint = GetMousePos();
// Mouse button clicked, so start a new line
//line = new VectorLine("DrawnLine3D", new List<Vector3>(), capLineTex, capLineWidth, LineType.Continuous, Joins.Fill);
line = new VectorLine("DrawnLine3D", new List<Vector3>(), capLineTex, 1, LineType.Continuous, Joins.Fill);
line.endPointsUpdate = 1;
line.endCap = "RoundCap";
previousPosition = Input.mousePosition;
canDraw = true;
// Mouse button held down and mouse has moved far enough to make a new point
else if (Input.GetMouseButton(0) && (Input.mousePosition - previousPosition).sqrMagnitude > sqrMinPixelMove && canDraw)
var pointCount = line.points3.Count;
// Set size for Line
if (line.GetSegmentNumber() > 0 && line.GetSegmentNumber() < 11)
List<float> temp = new List<float>();
for (int i = 0; i < line.GetSegmentNumber(); i++)
line.lineWidth = temp[temp.Count - 1]; // Set width to last biggest segment, done to make Endcaps same size.
line.smoothWidth = true;
if (pointCount >= maxPoints)
canDraw = false;
previousPosition = Input.mousePosition;
No, sorry; the idea of Vectrosity is that it draws vector lines, where they maintain the same width regardless of distance from the camera. In any case, you've set endPointsUpdate to 1, which makes only the last point update, which prevents smoothWidth from being able to function (since it needs to be able to adjust a couple of points in order to smooth the width). Also, I'm not entirely sure what you intend, but SetWidths can take a single number for a particular segment specified by an index, which seems like you would be able to use in order to avoid continuously allocating new lists.
Ahh, thank you very much for the hasty replies. Yes, that fixed my line smoothing issue, although it causes an 'Array index is out of range' error to happen every time I start drawing for some reason. The reason I am recreating the list every time is because the code is from an older version of Vectrosity where I was using an array and had to update the widths of the whole line every time if I recall correctly, good to see it can now be modified point by point.
Last question, is there a way to do billboarding of the line so that it is drawn in 3D but always facing the camera? I know there is Draw3DAuto(), this makes billboarding work, but it has the extra unwanted affect of resizing the line... so that the further away from the line I walk the bigger it gets and the closer I get, the smaller it gets. Without the billboarding, the line tends to look a bit messy in VR (especially if the person draws in the Z direction from the camera).
Do you know how I would change line colour/alpha based on distance from camera?
That shouldn't happen; if you have a code example where this happens, I can fix the bug. (I tried the code you posted and am not getting errors.)
No, sorry; as I mentioned above, the intention of Vectrosity is to create vector lines where the width is consistent regardless of distance from the camera.
I'd use Vector3.Distance, and plug that into Mathf.InverseLerp, which would get you a 0.0 - 1.0 value that you can use for the alpha.
In your DrawLinesTouch demo scene.... Im trying to change the width of the Drawn line with
line.lineWidth =24 ; line.Draw();
But it only scales the first segment of the line... >.<
Is there a way to scale the whole line?
Same as the issue a few posts above...endPointsUpdate in that script is set to 2, so only the last two points are updated (saves having to re-compute the whole line if you're just adding a segment to the end, so it uses hardly any CPU time). If you're changing stuff like line width that affects the whole line, then endPointsUpdate shouldn't be used.
Thanks, for both the questions I've asked recently
In Line Maker, and I'm getting greedy here, could you implement a connect points where you specify a minimum angle for the edge? Like the "Smoothing angle" on a mesh import.
Also for drawing dots with LineType.Points could you add a separate x/y scale?
I'm not really sure what you mean?
I'll put that on the to-do list.
So say in the example image only the orange edges would become lines
OK, I'll see what I can do.
If I'm using VectorManager to setup objects is there anyway to use useDraw3D on a per object basis?
No, sorry. If you want to mix Draw and Draw3D you'd need to create VectorLines and manage them yourself (which is pretty easy anyway).
Cheers, thanks for the makespline confusion, I ended up coding the plot points in the end and I'm happy the way it works.
Now I'm one step away from greatness with this thing - ie one last problem (for now... heh).
Ideally I want to render the lines in world space. I want to move them around and always be facing the camera. Constant Draw3D (or Draw3DAuto) only updates the lines rotations to face the camera if the camera moves, not if they move themselves (and the camera stays still).
Is there a way around this?
Alternatively I can render them on the canvas, and if the canvas is set to world space then I've got a decent alternative, but it seems to forcibly change the canvas back to screen space overlay every time. Bug or by design? Yes I could re-force it back to world space but I feel like I'm doing something wrong, fighting against vectrosity workflow or something. Thoughts?
I'm not quite sure what you mean; lines already do update if the line points move. Unless you're talking about actually moving the line's transform component? If so, that's not supported; the way to "move" lines is to update the points, or else use VectorLine.drawTransform.
By design; using a canvas is for 2D lines with Vector2 points. 3D lines with Vector3 points are meshes in world space.
I just had to update to the latest Unity 5.5 beta and have come across an error with Vectrosity.
All the lines materials suddenly don't seem to work anymore and instead appear black. I'm using the VectorLineGlow Material from the Demos folder. Is this a known bug?
I tried messing around with the material settings.
The problem doesn't happen in the Unity Editor, but only in the Windows build.
(Mac build is not affected either.)
Boom! Yeah drawTransform is the one. Nice.
That's a really weird quirk having to link it to another transform instead of using the lines transform, but I'll go with it because it does what I want now.
Previously I was updating the points manually and it was a pain in the ass, then I was rendering them (2D as you say) on a canvas but if it's set to canvas world space render mode then I could at least move them on the z-axis and apply screen effects etc, but I hated that solution.
Anywho drawTransform is the real hero of the day here. Cheers!
It's not a known bug and I can't get it to fail here, but cases where certain platforms behave unexpectedly is generally a bug in Unity; there's no particular reason why it should behave differently in a build. Try using a different shader; also a bug report to Unity would probably help (you can include Vectrosity if needed).
I had to upgrade to 5.4.3 and the problem was still there. Luckily I found an easy solution and wanted to share just in case if that helps you with the next version or for anyone looking a solution.
I was originally calling VectorLine.SetCanvasCamera (Camera.main) before creating the line. Simply moving it after creating and drawing the line fixed the scaling problem with the canvas.
Something strange happens when using draw3D at glancing angles. Here's how it is not using draw3D:
And this is using draw3D:
As you can see the lines running along Z are missing the red area of texture. You can see what a problem it becomes in the real situation:
Is it possible to fix this?
That's a limitation of UV mapping with the texture being stretched along a single quad. As far as I know the only real way to fix that is to subdivide the lines into multiple points instead of just 2, so there are more quads.