- Home /
Vectrosity line with arrow
I'm currently trying to create an editor allowing the user to make a tree graph by creating nodes and edges. Right now I'm using Vectrosity to draw out the edges and it's working great. But as it is intended to be a directed graph, it would be visibly more intuitive if the edges had an arrow to indicate direction.
Is there any way to draw arrows with Vectrosity or otherwise?
It's a great line-drawing tool on the asset store, you might want to check it out if you want lines in your game
Answer by Eric5h5 · Jun 07, 2012 at 03:27 AM
You could use some kind of arrow texture along with SetTextureScale, so the lines would look something like this:
Trying out this idea, but pretty bad at art stuffs so not too sure how to set textures and stuff.
I'm using this now:
// copied this off the default material from Vectrosity
$$anonymous$$aterial mat = new $$anonymous$$aterial("Shader \"Vertex Colors/Alpha\" {Category{Tags {\"Queue\"=\"Transparent\" \"IgnoreProjector\"=\"True\" \"RenderType\"=\"Transparent\"}SubShader {Cull Off ZWrite On Blend SrcAlpha One$$anonymous$$inusSrcAlpha Pass {BindChannels {Bind \"Color\", color Bind \"Vertex\", vertex}}}}}");
mat.SetTexture("_$$anonymous$$ainTex", arrowTexture);
VectorLine newEdge = new VectorLine("Edge", points, Color.cyan, mat, 5f, LineType.Discrete);
newEdge.SetTextureScale(1.0f);
newEdge.Draw3DAuto();
So far I'm not seeing the texture, a normal line is still being drawn. I must be doing something wrong with setting the texture, can anyone help please?
Create the material in Unity, make a public variable for the material, drag the material you made onto the appropriate slot in the inspector, and use that variable when creating the VectorLine. See any of the examples that use dot/dashed lines.
Did this work for you? I'm trying to achieve something similar but the texture always gets stretched and blurred.
Thanks Eric. I've tried this but the result isn't what I expect. It's as if one column of pixels gets repeated but not the rest of the texture. Either my arrow still appears only once in each segment, or it appears in the first segment and all the following segments are either single or triple lines. I need to get some pics up on my other post to illustrate.