dynamically line

Bonjour à tousl,

je voudrais savoir comment tracer un rectangle dynamiquement avec un contour de 1 pixel.
J’ai lu quelques tutos et je pense qu’il faut renter le code suivant :

var = GetComponent();

Mais ce n’est pas du tout ça.

Merci pour voter aide,

A+

You can do this with Unity UI.Images this way:

See enclosed FineUILines.unitypackage… it uses “sliced images” that have “fill interior” false.

You can make one rectangle, then instantiate copies of it and write code to modify the dimensions of the rectangle in real time.

Alternately, you can use a package such as Vectrosity:

5866663–624181–FineUILines.unitypackage (5.53 KB)

Hi all,

I want to create a 2D line horizontaly, or vertically of 1 pixel width.

I have tried your code (see below) :

VectorLine.SetLine (Color.yellow, Vector2(0, 0), Vector2(100, 200));

But the debugger find 3 errors (Vector2 et VectorLine).

I have tried with uses Vectrosity (Maybe it is a package library, I don’t know it, please how does it works)

Moreover, the line has to be created dynamically,

many thanks,

A+

VectorLine.SetLine (Color.yellow, Vector2(0, 0), Vector2(100, 200));

This is not valid C# code… you need a new keyword before each Vector2 creation.

You can also use the Unity3D built-in LineRenderer but you will need to do your own math to identify the size of a pixel in your world, and then scale the line appropriately.

And yes, Vectrosity is a line package. The link to the forum above contains a link to the asset store. It’s a good package.

Hi,

The keyword new with the Vector2 work very well but it rests a bug with the first word (Vectorline).
In effect tis one is highlighted in red.

Thanks to you,

A+

What library is VectorLine contained in? Where is the documentation? Hint: it is not a native part of the Unity3D API, as far as I know.

Coincidentally there is an object by that name in Vectrosity. Did you look at that documentation? Did you purchase and install that library?