This is the 12th day of my participation in the August More Text Challenge. For details, see:August is more challenging

The sity draws lines.

Unity Line drawing plugin Vectrosity 🔥

The Vectrosity plug-in 👍!

First, let’s introduce ourselves 👇

Vectrosity:” My name is Vectrosity😛, and I work as a Unity developer. My job is to make bosses’ needs as simple and convenient as possible. I can draw lines of various shapes in 2D and I can draw lines in 3D. In general, I am a line painter in Unity 🙉

Vectrosity is used to draw lines between 2d and 3D using the sitsity app, which is used to draw lines between 2d and 3D.

Example: tada:

The following simple to show you a small Demo(first ignore my drawing ability ha ha ha hiccup ~), just part of the plug-in content, because there are many functions, so here is only a brief introduction to a few functions, how to use their own plug-in can be further studied

Code test: TADA:

**2d :bell: **

After drawing 2d lines and importing the plug-in, create a script import namespace: Using Vectrosity; C#:

public class line : MonoBehaviour {

    void Start()
    {
        // Define a VectorLine object named "Line" using the points in the linePoints array and using the default material. The width of the Line is 10 pixels
        var linePoints = new List<Vector2>() { new Vector2(200.100), new Vector2(200.300)}; VectorLine line =new VectorLine("Line", linePoints, 10); line.Draw(); }}Copy the code

Effect diagram: Tada: :So we draw a line starting with Vector2(200, 100) and ending with Vector2(200, 300), where the frame is the lower left corner of the canvas (0,0).

3d: Santa: There are many ways to draw a 3D line. Here are two ways to show you how to draw a 3D line. After importing the plug-in, create the script import namespace using Vectrosity. C#:

public class line : MonoBehaviour {

    public GameObject[] points;
    public GameObject[] points2;

    private Vector3[] lineList2;
    private VectorLine line2;

    void Start()
    {
        OnDraw3D();
        t3d();
    }
    /// <summary>
    ///1.3D The line between objects
    /// </summary>
    private void OnDraw3D()
    {
        List<Vector3> lineList1 = new List<Vector3>() { points[0].transform.position, points[1].transform.position };
        VectorLine line1 = new VectorLine("line1", lineList1, 10f);
        line1.Draw3DAuto();
    }
    
    /// <summary>
    ///2.3D The line between objects
    /// </summary>
    void t3d()
    {
        lineList2 = new Vector3[] { points2[0].transform.position, points2[1].transform.position };
        line2 = VectorLine.SetLine3D(Color.black, 50f, lineList2); line2.Draw3DAuto(); }}Copy the code

Christmas_tree: :Ear: The first method is to define an array of GameObjects, pass the positions of the objects in the array in the VectorLine() method, and then scrib between the two objects. You can also use a map or change the color of the line.

:ear: The second method uses not a VectorLine, but vectorline.setline3D. This is another line drawing method in the VectorLine plug-in. Here we simply use one of the three 3d line drawing methods.


: Speech_balloon: VectorLine has 12 constructs, as shown below. The code above uses the simplest of the twoThe parameters in the VectorLine() method are

VectorLine(string name, List<Vector2> points, Texture texture, float width, LineType lineType, Joins joins);
Copy the code

String is the name of the drawn line. List Points are 2d or 3D coordinates. List Texture is the Texture of the drawn line. Float Width is the thickness of the drawn line LineType is an enumeration, my test found that the graph drawn with three parameters does not change significantly…

    public enum LineType
    {
        Continuous = 0,
        Discrete = 1,
        Points = 2
    }
Copy the code

Joins are also an enumeration, and tests showed no significant change in the graph drawn with three parameters…

    public enum Joins
    {
        Fill = 0,
        Weld = 1,
        None = 2
    }
Copy the code

Here is an example of how Joins are processed:

Code: a balloon…


Because there are many lines in VectorLine, I just introduced a simple and convenient one, if the need for lines is more small friends can use the plug-in to further study oh this is the encapsulated line call interface, look at super many

Conclusion: house:

Well, that’s it. This article is just a brief introduction to the VectorLine plug-in and one of the simpler and more convenient methods. If you want to explore further, you can download it yourself.

VectorLine plug-in download 1 credits, may increase, credits are not enough for private messages oh

Here are some example effects from the plugin: