Vectrosity Reference Guide
Vectrosity Reference Guide
VectorPoints
VectorLine functions
AddNormals ........................................10
AddTangents .......................................10
Draw ....................................................10
Draw3D ................................................10
Draw3DAuto ........................................11
GetColor ..............................................11
GetLength ...........................................11
GetPoint ..............................................11
GetPoint01 ..........................................12
GetPoint3D ..........................................12
GetPoint3D01 ......................................12
GetSegmentNumber ...........................13
GetWidth .............................................13
MakeArc ..............................................14
MakeCircle ..........................................15
MakeCube ..........................................15
MakeCurve ..........................................16
MakeEllipse .........................................17
MakeRect ............................................18
MakeRoundedRect .............................19
MakeSpline .........................................20
MakeText .............................................21
MakeWireframe ...................................21
Resize ..................................................21
Selected ..............................................22
SetColor ..............................................23
SetColors ............................................23
SetDistances .......................................23
SetWidth ..............................................24
SetWidths ...........................................24
StopDrawing3DAuto ...........................24
Constructs a VectorLine object with the supplied parameters. The parameters after lineWidth are optional
and have the default values indicated, though if you supply joins, you must also supply lineType.
name is a string thats used to name the mesh created for the vector line. Its also used in the name of the
GameObject that this constructor generates, where the complete name is Vector plus the supplied name.
The name is also used to identify bounds meshes made with VectorManager.ObjectSetup.
points is a Vector2 or Vector3 array, where each entry is a point in the line using screen-space coordinates (in
the case of a Vector2 array), or world units (in the case of a Vector3 array). Any points in the array are copied
to the VectorLine object and the array is no longer referenced afterward.
The line is drawn using the material supplied by material. If dierent line depths are used, the material should
use a shader that writes to the depth buer for this to work reliably. The shader should use vertex colors in
order for line segment colors to work. Note: if null is passed for the material, a default material is used. This
material uses a basic shader which works with vertex colors and line depths, but has no texture.
The lineWidth is the width in pixels. This is a float, so values like 1.5 are acceptable.
lineType is either LineType.Discrete or LineType.Continuous. For discrete lines, each line segment is made
from two entries in the Vector2 array. For continuous lines, the line starts at entry 0, and each segment is
continuously connected to the next point until the end is reached.
joins is one of Joins.None, Joins.Fill, or Joins.Weld. Joins.None is the default and draws line segments as
standard rectangles, primarily used with thin lines. Joins.Fill will fill in the gaps seen where lines join at an
angle, primarily used with thick lines with no texture. This only works if using LineType.Continuous.
Joins.Weld is similar, except vertices of sequential line segments are welded, which makes it more
appropriate for textured lines. Joins.Weld works with LineType.Discrete, but only for sequential line
segments.
active
var active : boolean;
Sets a VectorLine active or inactive. Inactive VectorLines wont be rendered, and if an inactive VectorLine is
used with functions like Draw, the function will return immediately without doing anything.
canvasID
var canvasID : int = 0;
Sets the VectorLines canvas ID, where each ID refers to a dierent canvas. Theres always at least one
canvas, which has the default ID of 0. If the supplied value refers to a canvas that doesnt exist, its created
automatically. There are two sets of canvases, one for lines made with VectorLine.Draw and another for lines
made with VectorLine.Draw3D. See VectorLine.canvases and VectorLine.canvases3D.
capLength
var capLength : float = 0;
Sets the lines capLength to the supplied float. This is the number of pixels added to either end of the line (0
by default). Typically used for filling in gaps seen in thick lines when they are joined at right angles, such as
when drawing selection boxes or other rectangles. Only works with lines made with Vector2 points.
collider
var collider : boolean = false;
If true, the line will generate a matching 2D collider when its drawn. The collider is updated if the line is
changed and re-drawn. Setting this to false will disable the collider, if one existed previously. Works with lines
made with Vector3 points as well as lines made with Vector2 points. Since 2D colliders are on the X/Y plane
only, the camera should be facing along the Z axis, with no rotation, in order for the collider to correctly
match the line.
color
var color : Color = Color.white;
The color of the VectorLine. When set, all line segments are colored with the supplied value. See also
VectorLine.SetColor and VectorLine.SetColors. Note that VectorLine.color will retain its original value even if
all line segments have been set to dierent colors when using SetColor or SetColors. The default value is
Color.white when a VectorLine is first constructed.
continuous
var continuous : boolean; (read only)
True if the VectorLine was made with LineType.Continuous, false if it was made with LineType.Discrete.
continuousTexture
var continuousTexture : boolean = false;
If this is set to true, then any texture used for the line will be stretched evenly along the entire length of the
line, regardless of how many points make up the line or how far apart the points are spaced. If set to false,
then the texture is repeated once for every line segment (which is the default).
drawDepth
var drawDepth : int;
The sibling index of the VectorLine as drawn in the vector canvas. Lines with higher drawDepth values are
drawn on top of lines with lower drawDepth values. Each line has a unique drawDepth value, which is
assigned in order as more VectorLines are created, so changing the drawDepth value for one line may
change the values of others. The minimum is 0, and the maximum depends on the number of VectorLines
parented to an object (which is the vector canvas by default, but can be changed using
VectorLine.rectTransform).
drawEnd
var drawEnd : int;
Specifies the index in the VectorLines points list at which line drawing should end. Any later points will be
erased when VectorLine.Draw is called. (Erased on-screen, not from the points array.) When used with a
discrete line, drawEnd should be an odd number, although it can be 0. If its even (aside from 0), it will be
incremented to the next highest integer. Its clamped between 0 and points.Count-1. This can be used with
drawStart to specify a range of points to draw in a line.
drawStart
var drawStart : int;
Specifies the index in the VectorLines points list at which line drawing should start. Any earlier points will be
erased when VectorLine.Draw is called. (Erased on-screen, not from the points array.) When used with a
discrete line, drawStart should be an even number. If its odd, it will be incremented to the next highest
integer. Its clamped between 0 and pointsArray.Length-1.
drawTransform
var drawTransform : Transform;
When drawn, the line is modified by the supplied transform. For example, if the transform is located at
Vector3(5.0, 2.0, 0.0), then the line is oset by 5 units on the X axis and 2 units on the Y axis. A transform
thats rotated will cause the line to be rotated by the same amount, and a transform thats scaled will cause
the line to be scaled by the same amount, though it will always be drawn with the correct thickness. If the
transform is modified, the line will need to be re-drawn in order to reflect the changes.
endCap
var endCap : String;
Specifies an end cap for the VectorLine, using a name as defined in SetEndCap. The name is case-sensitive,
and SetEndCap must have been called before an end cap can be added. If null or is used for the string,
then the end cap is removed from the VectorLine.
endPointsUpdate
var endPointsUpdate : int = 0;
The number of points from the end of the VectorLine that are actually updated when Draw or Draw3D is
called. The other points will be untouched. This is intended to be used as an optimization for cases where
most of the line stays the same and does not need to be recomputed when re-drawn.
Note that when used with discrete lines, endPointsUpdate always uses even numbers. If odd numbers are
supplied, they will be rounded up to the next even number, so 1 becomes 2 and so on.
is2D
var is2D : boolean;
Returns true if the VectorLine was made with Vector2 points, false otherwise.
joins
var joins : Joins;
Returns the Joins type that was used when the line was created, and can be used to change the Joins type
at any time. Does nothing if Joins.Fill is used with a discrete line. Also does nothing if the line is VectorPoints
and either Joins.Fill or Joins.Weld are used.
lineWidth
var lineWidth : float;
The width of the line, in pixels. This can be used to change the width of a VectorLine object after its been
declared. If a VectorLine has multiple widths, then setting lineWidth will set all widths in the array to the
supplied value, and reading lineWidth will return the value of the first entry in the array. VectorLine.Draw must
be called after setting the lineWidth value for the eect to be visible on-screen.
material
var material : Material;
Returns the material that was used when the VectorLine was set up, and can be used to assign a dierent
material at any time after the line has been created.
matrix
var matrix : Matrix4x4;
The line will be modified by the supplied Matrix4x4 when its drawn. This is similar to using drawTransform,
except no other object is required since the matrix is supplied directly.
maxWeldDistance
var maxWeldDistance : float;
The number of pixels that a weld can extend, from where a given line segment joins with the next line
segment. If this distance is exceeded, the weld is cancelled. By default, maxWeldDistance is twice the pixel
width of the line when it was created.
name
var name : string;
Returns the name of the VectorLine, which is initially the string that was supplied when the VectorLine was
constructed. The name can be changed at any time.
physicsMaterial
var physicsMaterial : PhysicsMaterial2D;
If a collider is used for the line, it will have the supplied PhysicsMaterial2D.
points2
var points2 : List<Vector2>;
This is a reference to the list of Vector2 points that was used when the line was set up. The entries in the
array can be changed at any time, and then VectorLine.Draw used to draw the line with the updated points.
Standard generic List functions such as Add and RemoveAt can be used to change the count of the list. (See
also Resize.) If the line was made with Vector3 points, then accessing points2 will result in an error. Use is2D
to determine if a line was made with Vector2 points.
points3
var points3 : List<Vector3>;
Similar to points2, except its a reference to the list of Vector3 points that was used when the line was set up.
If the line was made with Vector2 points, then accessing points3 will result in an error. Use is2D to determine
if a line was made with Vector2 points.
rectTransform
var rectTransform : RectTransform;
A reference to the RectTransform component of the VectorLine. This can be used to manipulate the position
of the line, but in most cases this is not recommended; use drawTransform instead. The primary use is to set
the parent of the rectTransform to another object in the vector canvas, in order to control rendering order.
smoothColor
var smoothColor : boolean = false;
Should line segment colors in this VectorLine be smoothly interpolated between segments? By default this is
false, so each segment has its own discrete color. Line segment colors are set with VectorLine.SetColor and
VectorLine.SetColors.
smoothWidth
var smoothWidth : boolean = false;
Should line segment widths in this VectorLine be smoothly interpolated between segments? By default this is
false, so each segment has its own discrete width. Line segment widths are set with VectorLine.SetWidth and
VectorLine.SetWidths.
textureOset
var textureOffset : float = 0.0;
Used in combination with textureScale. If the value of textureScale is not 0.0, then the texture will be
horizontally oset (relative to the line) proportionally by the amount specified in textureOset.
textureScale
var textureScale : float = 0.0;
Used for making uniform-scaled textures, such as dotted or dashed lines. If not 0.0, then the width of the
texture supplied by the lines material is scaled by the specified amount compared to its height, and the
texture is repeated this way for the length of the line. For example, a value of 1.0 means a square texture
would be as wide as it is high.
trigger
var trigger : boolean = false;
If VectorLine.collider has been set, then VectorLine.trigger controls whether the collider is set as a trigger or
not.
useViewpointCoords
var useViewportCoords : boolean = false;
If true, the line (or points) is drawn with viewport coordinates, where Vector2(0.0, 0.0) is the lower-left corner
of the screen, and Vector2(1.0, 1.0) is the upper-right corner, regardless of resolution. Works with Vector2
coordinates only.
VECTORPOINTS
Constructs a VectorPoints object for a Vector2 array with the supplied parameters. name is a string thats
used to name the mesh created for the vector points. Its also used in the name of the GameObject that this
constructor generates, where the complete name is Vector plus the supplied name.
points is a Vector2 or Vector3 array, where each entry is a point using screen-space coordinates (for Vector2
arrays) or world-space coordinates (for Vector3 arrays).
The points are drawn using the material supplied by material. If dierent depths are used, the material
should use a shader that writes to the depth buer for this to work reliably. The shader should use vertex
colors for point colors to work. If null is passed for the material, a default material is used. This material uses
a basic shader which works with vertex colors and line depths, but has no texture.
The width is the width in pixels. This is a float, so values like 1.5 are acceptable.
Most functions that accept a VectorLine object will also work with VectorPoints, such as Draw, Draw3D,
MakeCurve, etc. Most of the variables for VectorLine (depth, minDrawIndex, etc.) work with VectorPoints,
except for capLength, joins, maxWeldDistance, and smoothWidth.
VECTORLINE FUNCTIONS
10
VectorLine functions are used with a VectorLine object. For example, if myLine is a VectorLine, then
myLine.Draw() or myLine.MakeRect (someRect).
AddNormals
function AddNormals () : void
Creates normals for a VectorLine. This should be called when a material that has a shader which requires
normals is used for the VectorLine. If the line has already been drawn, it should be re-drawn after using
AddNormals in order for the normals to actually be applied.
AddTangents
function AddTangents () : void
Creates mesh tangents for a VectorLine. This should be called when a material that has a shader which
requires tangents is used for the VectorLine. AddNormals is called automatically whenever AddTangents is
called, since tangents require normals. If the line has already been drawn, it should be re-drawn after using
AddTangents in order for the tangents to actually be applied.
Draw
function Draw () : void
Draws the VectorLine or VectorPoints object using the vector canvas. Lines with either Vector2 or Vector3
points can be used. If the line uses Vector3 points, and VectorLine.SetCamera3D has not been called, then
SetCamera3D is called automatically (using Camera.main) the first time Draw is used.
Draw3D
function Draw3D () : void
Draws the VectorLine object in 3D space using the vector3D canvas. The points used to create the
VectorLine object must be Vector3. If VectorLine.SetCamera3D has not been called, then its called
automatically (using Camera.main) the first time Draw is used. Since the lines exist in the scene and are not
drawn in a separate overlay as they are with Draw, they must be updated when the camera used in
SetCamera3D changes position or else they will no longer have the correct appearance. See also
Draw3DAuto.
VECTORLINE FUNCTIONS
11
Draw3DAuto
function Draw3DAuto (time : float = Mathf.Infinity) : void
Draws the VectorLine object in the same way as Draw3D, but automatically updates the line every frame.
Therefore, lines drawn with Draw3DAuto dont need to be updated manually and will always appear correct
regardless of camera movement and so on.
The optional time is the number of seconds for which the line will be drawn, after which its destroyed. The
default is that the line is never destroyed.
GetColor
function GetColor (index : int) : Color
GetLength
function GetLength () : float
Returns the total length of all line segments that make up the VectorLine. The length refers to pixels when
used with Vector2 lines, and world units when used with Vector3 lines. If the points that make up the line
array are changed after GetLength is called, then SetDistances should be called before using GetLength
again in order to maintain accurate segment distances.
GetPoint
function GetPoint (distance : float) : Vector2
Returns a Vector2 in screen-space coordinates that corresponds to the given distance in the VectorLine. If
distance is equal to or less than 0, then the first point in the VectorLine is returned. If the distance is equal to
or greater than the total length of the line as defined by GetLength, then the last point in the VectorLine is
returned. The first and last points are clamped by the VectorLines drawStart and drawEnd values. If the
points that make up the line array are changed after GetPoint is called, then SetDistances should be called
before using GetPoint again in order to maintain accurate segment distances.
As above, but the out parameter index will contain the line segment index that corresponds to the distance.
VECTORLINE FUNCTIONS
12
GetPoint01
function GetPoint01 (distance : float) : Vector2
Same as GetPoint, except that distance is normalized between 0.0 and 1.0, where 0.0 is the first point in the
VectorLine and 1.0 is the last point in the VectorLine.
As above, but the out parameter index will contain the line segment index that corresponds to the distance.
GetPoint3D
function GetPoint3D (distance : float) : Vector3
Returns a Vector3 in world-unit coordinates that corresponds to the given distance in the VectorLine. If
distance is equal to or less than 0, then the first point in the VectorLine is returned. If the distance is equal to
or greater than the total length of the line as defined by GetLength, then the last point in the VectorLine is
returned. The first and last points are clamped by the VectorLines drawStart and drawEnd values. If the
points that make up the line array are changed after GetPoint3D is called, then SetDistances should be called
before using GetPoint3D again in order to maintain accurate segment distances.
As above, but the out parameter index will contain the line segment index that corresponds to the distance.
GetPoint3D01
function GetPoint3D01 (distance : float) : Vector3
Same as GetPoint3D, except that distance is normalized between 0.0 and 1.0, where 0.0 is the first point in
the VectorLine and 1.0 is the last point in the VectorLine.
As above, but the out parameter index will contain the line segment index that corresponds to the distance.
VECTORLINE FUNCTIONS
13
GetSegmentNumber
function GetSegmentNumber () : int
Returns the number of line segments that it would be possible to make with the given VectorLine. This is the
number of points in VectorLine.points2 or VectorLine.points3 minus one for continuous lines, and half the
number of points for discrete lines. For VectorPoints, it returns the total number of points.
GetWidth
function GetWidth (index : int) : float
VECTORLINE FUNCTIONS
14
MakeArc
function MakeArc (origin : Vector2 or Vector3,
up : Vector3 = Vector3.forward,
xRadius : float,
yRadius : float,
startDegrees : float,
endDegrees : float,
segments : int = all,
index : int = 0) : void
Creates a section of an ellipse in VectorLine.points2 or VectorLine.points3. For Vector2, the supplied origin is
in screen space pixels, as are the supplied radii. Vector3 uses world space coordinates. xRadius is the
horizontal radius of the ellipse, and yRadius is the vertical radius. If both are the same, the arc will be made
from a circle.
The optional up vector indicates the orientation of arcs when drawn using Vector3 points. It has no eect
when using Vector2 points. The default up vector of Vector3.forward means that the arc is drawn in the X/Y
plane. Using Vector3.up would mean that the ellipse would be drawn in the X/Z plane. The up vector can be
any arbitrary vector and does not need to be normalized.
The startDegrees is the number of degrees around the ellipse that the arc will be started. The degrees go in
a clockwise direction. The endDegrees is the number of degrees around the ellipse that the arc will finish. If
the degrees are over 360 or below 0, they wrap around.
The optional segments indicates how many line segments will be used to create the arc, with a minimum of
3. This is normally used with the index parameter to create multiple arcs in the same VectorLine. If segments
is omitted, then all of the points in VectorLine.points2 or VectorLine.points3 will be used.
The optional index is 0 by default, though it can be anything, as long as the number of segments would fit in
VectorLine.points2 or VectorLine.points3. This allows creation of multiple arcs in the same line, since the
points used to create the arc start at the value defined by index. The count of VectorLine.points2 or
VectorLine.points3 must be at least the number of segments specified plus one if the line was created as
continuous line, or twice the number of segments if it was created as a discrete line. Note that specifying the
index also requires that segments be specified.
VECTORLINE FUNCTIONS
15
MakeCircle
function MakeCircle (origin : Vector2 or Vector3,
up : Vector3 = Vector3.forward,
radius : float,
segments : int = all,
pointRotation : float = 0.0,
index : int = 0) : void
Creates a circle in VectorLine.points2 or VectorLine.points3. If using Vector2, the supplied origin is in screen
space pixels, as is the supplied radius. If using Vector3, the coordinates are world space.
The optional up vector indicates the orientation of circles when drawn using Vector3 points. It has no eect
when using Vector2 points. The default up vector of Vector3.forward means that the circle is drawn in the X/Y
plane. Using Vector3.up would mean that the circle would be drawn in the X/Z plane. The up vector can be
any arbitrary vector and does not need to be normalized.
The optional segments indicates how many line segments will be used to create the circle, with a minimum
of 3. This is normally used with the index parameter to create multiple circles in the same VectorLine. If
segments is omitted, then all of the segments in the VectorLine will be used.
The optional pointRotation describes how many degrees clockwise the points will be rotated around the
origin. Negative values rotate the points counter-clockwise.
The optional index is 0 by default, though it can be anything, as long as the number of segments would fit in
VectorLine.points2 or VectorLine.points3. This allows creation of multiple circles in the same line, since the
points used to create the circle start at the value defined by index. The length of VectorLine.points2 or
VectorLine.points3 used for line must be at least the number of segments specified plus one if the line was
created as continuous line, or twice the number of segments if it was created as a discrete line. Note that
specifying the index also requires that segments be specified.
MakeCube
function MakeCube (origin : Vector3,
xSize : float,
ySize : float,
zSize : float,
index : int = 0) : void
Creates a cube in VectorLine.points3 (which must have a count of at least 24). The VectorLine must be
LineType.Discrete. The origin is the world-space coordinate for the center of the cube. The xSize, ySize, and
zSize are floats indicating how many units in size the cube is for those dimensions. The optional index is 0
by default, though it can be anything, as long as the count of VectorLine.points3 is at least 24 plus the index.
VECTORLINE FUNCTIONS
16
MakeCurve
function MakeCurve (curvePoints : Vector2[] or Vector3[],
segments : int,
index : int = 0) : void
The anchor and control points for the curve are defined as individual Vector2s or Vector3s rather than a
Vector2[] or Vector3[] array, but otherwise this is the same as above. The Vector2s use screen space pixel
coordinates, and Vector3s use world space coordinates.
As above, but since the number of segments isnt specified, the maximum allowed by the total count in
VectorLine.points2 or VectorLine.points3 will be used.
VECTORLINE FUNCTIONS
17
MakeEllipse
function MakeEllipse (origin : Vector2 or Vector3,
up : Vector3 = Vector3.forward,
xRadius : float,
yRadius : float,
segments : int = all,
pointRotation : float = 0.0,
index : int = 0) : void
Creates an ellipse in VectorLine.points2 or VectorLine.points3. For Vector2, the supplied origin is in screen
space pixels, as are the supplied radii. Vector3 uses world space coordinates. xRadius is the horizontal
radius of the ellipse, and yRadius is the vertical radius.
The optional up vector indicates the orientation of ellipses when drawn using Vector3 points. It has no eect
when using Vector2 points. The default up vector of Vector3.forward means that the ellipse is drawn in the X/
Y plane. Using Vector3.up would mean that the ellipse would be drawn in the X/Z plane. The up vector can
be any arbitrary vector and does not need to be normalized.
The optional segments indicates how many line segments will be used to create the ellipse, with a minimum
of 3. This is normally used with the index parameter to create multiple ellipses in the same VectorLine. If
segments is omitted, then all of the points in VectorLine.points2 or VectorLine.points3 will be used.
The optional pointRotation describes how many degrees clockwise the points will be rotated around the
origin. Negative values rotate the points counter-clockwise.
The optional index is 0 by default, though it can be anything, as long as the number of segments would fit in
VectorLine.points2 or VectorLine.points3. This allows creation of multiple ellipses in the same line, since the
points used to create the ellipse start at the value defined by index. The count of VectorLine.points2 or
VectorLine.points3 must be at least the number of segments specified plus one if the line was created as
continuous line, or twice the number of segments if it was created as a discrete line. Note that specifying the
index also requires that segments be specified.
VECTORLINE FUNCTIONS
18
MakeRect
function MakeRect (rect : Rect,
index : int = 0) : void
Creates a rectangle in VectorLine.points2 or VectorLine.points3. The supplied rect is in screen space pixels if
using Vector2, or world space coordinates if using Vector3.
The optional index is 0 by default, though it can be anything, as long as the rect would fit in
VectorLine.points2 or VectorLine.points3. This allows creation of multiple rectangles in the same line, since
the points used to create the rectangle start at the value defined by index. The length of VectorLine.points2
or VectorLine.points3 must be at least 5 if the line was created as continuous line, or 8 if it was created as a
discrete line.
As above, but the supplied bottomLeft and topRight describe the respective corners of the rectangle in
screen space pixels if using Vector2, or world space coordinates if using Vector3.
VECTORLINE FUNCTIONS
19
MakeRoundedRect
function MakeRoundedRect (rect : Rect,
cornerRadius : float,
cornerSegments : int,
index : int = 0) : void
Creates a rectangle in VectorLine.points2 or VectorLine.points3. The supplied rect is in screen space pixels if
using Vector2, or world space coordinates if using Vector3.
The cornerRadius is the radius for each corner, measured in the number of pixels (for Vector2 lines) or world
units (for Vector3 lines).
The cornerSegments is how many line segments will be used for each corner. This must be at least 1.
The optional index is 0 by default, though it can be anything, and is normally used to create multiple
rectangles in the same line, since the points used to create the rectangle start at the value defined by index.
The number of segments required for a rounded rect is 4 * cornerSegments + 4 (to get the number of points
for a continuous line, add 1, and for a discrete line, multiply by 2).
If the VectorLine doesnt contain enough points to hold the rounded rect, more will automatically be added as
needed.
As above, but the supplied bottomLeft and topRight describe the respective corners of the rectangle in
screen space pixels if using Vector2, or world space coordinates if using Vector3.
VECTORLINE FUNCTIONS
20
MakeSpline
function MakeSpline (splinePoints : Vector2[] or Vector3[],
segments : int,
index : int = 0,
loop : boolean = false) : void
As above, but since the number of segments isnt specified, all the points in VectorLine.points2 or
VectorLine.points3 will be used.
VECTORLINE FUNCTIONS
21
MakeText
function MakeText (text : String,
position : Vector2 or Vector3,
size : float,
characterSpacing : float = 1.0,
lineSpacing : float = 1.5,
uppercaseOnly : boolean = true) : void
Creates the string text in the VectorLine. The text is placed at position using screen-space pixel coordinates
if used with Vector2 points, or world space coordinates if used with Vector3 points. size is the number of
pixels in height if used with Vector2 points, or world units if used with Vector3 points. Text is always
monospaced. Any characters not present in the default font are ignored. \n can be used as a newline
character. VectorLine.points2 or VectorLine.points3 will be resized as necessary to contain the number of
points needed for the text.
The optional characterSpacing is 1.0 by default, which is a relative value, where 1.0 equals size, 0.5 would
be half of size, etc. The optional lineSpacing is 1.5 by default, and is also a relative value in the same way. If
supplying either the character spacing or the line spacing, both values must be supplied.
The optional uppercaseOnly is true by default, which makes the text always display using uppercase
characters, even if text contains lowercase characters.
MakeWireframe
function MakeWireframe (mesh : Mesh) : void
Creates a wireframe in the VectorLine using all the triangles in mesh. The points used to create the
VectorLine must be Vector3, and the line must be created using LineType.Discrete. VectorLine.points3 will be
resized as necessary to contain the number of points needed for the wireframe.
Resize
function Resize (newCount : int) : void
Resizes the VectorLine.points2 or VectorLine.points3 count to the number specified by newCount. The size
must be at least 0 and less than the maximum available for the line type (16383 for continuous lines and
VectorPoints, and 32767 for discrete lines). Existing content of VectorLine.points2 or VectorLine.points3 is
untouched. If newCount is larger than the existing count, the new points will be filled with Vector2.zero or
Vector3.zero.
VECTORLINE FUNCTIONS
22
Selected
function Selected (position : Vector2,
cam : Camera = Camera.main) : boolean
Returns true if this VectorLine contains position, which is a screen-space coordinate, such as that provided
by Input.mousePosition. (Vector3 is implicitly cast to Vector2, so Input.mousePosition will work directly even
though its technically a Vector3.) If the camera is not supplied, the first camera tagged MainCamera is
used, if one exists.
Returns true if this VectorLine contains position. The index is an integer variable declared elsewhere, which
will contain the line segment index when passed in to the Selected function. If Selected returns false, then
index will contain -1. If using VectorPoints instead of VectorLine, then index is the point thats currently
selected rather than the line segment. If the camera is not supplied, the first camera tagged MainCamera is
used, if one exists.
Returns true if this VectorLine contains position. The extraWidth parameter is the number of pixels that a
lines width is expanded by for the purposes of determining whether it contains position, so that the position
doesnt need to be exact in order to register as being inside the line. The extra distance is for computation
only and does not aect the visual appearance of the line. As above, the index is an integer variable which
will contain the line segment index. If the camera is not supplied, the first camera tagged MainCamera is
used, if one exists.
Returns true if this VectorLine contains position. The extraWidth parameter is the number of pixels that a
lines width is expanded by for the purposes of determining whether it contains position. The extraLength
parameter is the number of pixels that each line segment is extended by for the purposes of determining
whether the line contains position; the actual visible line segments remain the same. The index is an integer
variable which will contain the line segment index. If the camera is not supplied, the first camera tagged
MainCamera is used, if one exists.
VECTORLINE FUNCTIONS
23
SetColor
function SetColor (color : Color32) : void
Sets all the line segment colors in the VectorLine to the supplied color. The line has its color changed
immediately without having to call VectorLine.Draw or Draw3D.
Sets the line segment specified by index to the supplied color. The other line segments are unaected. The
line has its color changed immediately without having to call VectorLine.Draw or Draw3D.
Sets the line segments specified by startIndex up to and including endIndex to the supplied color. The
other line segments outside of this range are unaected. The line has its color changed immediately without
having to call VectorLine.Draw or Draw3D.
SetColors
function SetColors (colors : Color32[]) : void
Sets all the line segment colors in the VectorLine to the supplied colors array. The line has its colors changed
immediately without having to call VectorLine.Draw or Draw3D. Each entry in the color array corresponds to a
line segment, so the length of the color array must be half the count of VectorLine.points2 or
VectorLine.points3 if using a discrete line, or the same as the points count minus one if using a continuous
line. When using VectorPoints, the length of the array should equal the points count. Whether each line
segment is a distinct color, or the colors are smoothly blended, is determined by VectorLine.smoothColor.
SetDistances
function SetDistances () : void
Used to recompute line segment distances in the VectorLine after changing any points in VectorLine.points2
or VectorLine.points3. If GetLength or any of the GetPoint functions have been used, and the line points are
changed, those functions will no longer return accurate information unless SetDistances is called before
using those functions again. SetDistances is automatically called when using GetLength or any of the
GetPoint functions for the first time.
VECTORLINE FUNCTIONS
24
SetWidth
function SetWidth (width : float) : void
Sets all the line segment widths in the VectorLine to the supplied width. VectorLine.Draw or Draw3D must be
called afterwards in order for altered line segment to show up correctly.
Sets the line segment specified by index to the supplied width. The other line segments are unaected.
VectorLine.Draw or Draw3D must be called afterwards in order for altered line segment to show up correctly.
Sets the line segments specified by startIndex up to and including endIndex to the supplied width. The
other line segments outside of this range are unaected. VectorLine.Draw or Draw3D must be called
afterwards in order for altered line segment to show up correctly.
SetWidths
function SetWidths (lineWidths : float[] or int[]) : void
Sets the pixel widths of the line segments in the VectorLine to the values supplied by the lineWidths array,
which can be either a float array or an int array. Each entry in the line widths array corresponds to a line
segment, so the length of the line widths array must be half the count of VectorLine.points2 or
VectorLine.points3 if using a discrete line, or the same as the points count minus one if using a continuous
line. When using VectorPoints, the length of the array should equal the points count. VectorLine.Draw or
Draw3D must be called afterwards in order for the new widths to show up. Whether each line segment is a
distinct width, or the widths are smoothly blended, is determined by VectorLine.smoothWidth.
StopDrawing3DAuto
function StopDrawing3DAuto () : void
25
VectorLine static functions are not used with a VectorLine object, but are called explicitly with VectorLine.
For example, VectorLine.SetCamera3D().
BytesToVector2Array
static function BytesToVector2Array (lineBytes : byte[]) : Vector2
Converts lineBytes to a Vector2 array, used for making complex line objects without having to use long
strings of hard-coded Vector2 array data in scripts. Typically lineBytes would be supplied by a TextAsset file,
specifically TextAsset.bytes. These TextAssets are made with the LineMaker editor script.
BytesToVector3Array
static function BytesToVector3Array (lineBytes : byte[]) : Vector3
Converts lineBytes to a Vector3 array, used for making complex line objects without having to use long
strings of hard-coded Vector3 array data in scripts. Typically lineBytes would be supplied by a TextAsset file,
specifically TextAsset.bytes. These TextAssets are made with the LineMaker editor script.
canvas
static var canvas : Canvas;
canvas3D
static var canvas3D : Canvas;
A reference to the vector canvas used by VectorLine.Draw3D and Draw3DAuto, so properties such as
sortingOrder can be changed. By default its set to RenderMode.World.
Note that any manual calls to SetCamera3D should be done before setting canvas3D. Otherwise, setting
canvas3D will attempt to call SetCamera with Camera.main.
VectorLine.canvas3D is the same as VectorLine.canvases3D[0].
canvases
static var canvases : List<Canvas>;
A reference to the list of vector canvases used by VectorLine.Draw, where each entry corresponds to the
canvasID used by a VectorLine. See also VectorLine.canvas.
26
canvases3D
static var canvases3D : List<Canvas>;
A reference to the list of vector canvases used by VectorLine.Draw3D, where each entry corresponds to the
canvasID used by a VectorLine. See also VectorLine.canvas3D.
Destroy
static function Destroy (ref line : VectorLine) : void
Removes a VectorLine (or VectorPoints) and all associated Unity objects from the scene. If line is null, its
ignored and no null reference exception errors will occur.
Removes a VectorLine and all associated Unity objects from the scene, and destroys gameObject at the
same time. If line or gameObject are null, they are ignored and no null reference exception errors will occur.
RemoveEndCap
static function RemoveEndCap (name : String) : void
Removes the end cap defined by name from the end cap library.
SetCamera3D
static function SetCamera3D (camera : Camera = Camera.main) : void
Sets the camera up for drawing lines made with Vector3 points. The optional camera is set to the first
camera in the scene found tagged Main Camera by default. SetCamera3D is called automatically when
using Draw or Draw3D for the first time, so its normally not necessary to call it manually, unless using a
camera other than Main Camera is desired. If the camera used with SetCamera3D is destroyed, such as by
scene changes, SetCamera3D should be called again with the desired camera.
27
SetCanvasCamera
static function SetCanvasCamera (camera : Camera);
Sets the vector canvas to RenderMode.OverlayCamera, and the canvas worldCamera to camera. By
contrast, the default RenderMode for the canvas is RenderMode.Overlay. SetCanvasCamera should be used
for VectorLines that use a shader which requires lighting, and it can be used with cameras that make use of a
RenderTexture, in order to render the vector canvas to a texture.
28
SetEndCap
static function SetEndCap (name : String,
capType : EndCap,
material : Material = null,
offsetFront : float = 0.0;
offsetBack : float = 0.0;
scaleFront : float = 1.0;
scaleBack : float = 1.0;
texture1 : Texture2D = null,
texture2 : Texture2D = null) : void
Creates a named end cap that can be used with VectorLine.endCap. There can be any number of dierent
end caps that exist in the end cap library, as long as each one uses a unique name. Once an end cap is set
up, it can be used by any VectorLine in any script, so SetEndCap should only be called once for each end
cap. (The end cap library exists only at runtime, not in the project.)
The name is case-sensitive.
The capType can be EndCap.Front, EndCap.Back, EndCap.Both, EndCap.Mirror, or EndCap.None.
EndCap.Front: only one texture needs to be supplied (texture1), and it will appear at the front of the line,
as defined by the first point in the array of points that makes up the VectorLine.
EndCap.Back: only one texture needs to be supplied (texture1), and it will appear at the back of the line,
as defined by the last point in the array of points that makes up the VectorLine.
EndCap.Both: two textures need to be supplied (texture1 and texture2), the first of which will appear at
the front of the line, and the second of which will appear at the back of the line.
EndCap.Mirror: only one texture needs to be supplied (texture1), which will appear at both the front and
back of the line, and the textures appearance at the back will be a mirror image compared to the front.
EndCap.None: the named end cap is removed from the end cap library, and the resources used to create
the end cap (specifically a custom texture and material created at runtime) are destroyed.
The material should normally (but not necessarily) be the same material that will be used when creating a
particular VectorLine, so that the end cap material will match the material used for the rest of the line. Note
that only one pair of end caps can be used for any given VectorLine, even if LineType.Discrete is used.
osetFront and osetBack are a percentage of the end caps length. By default (when the oset is 0.0), end
caps are added to the ends of the line. If the oset is set to -1.0, for example, the end caps will be moved
inward by their own length, so the line will be as long as it would have been without end caps. If osetBack is
omitted, then the oset used for osetFront will be applied to the front and back.
scaleFront and scaleBack are a percentage of the end caps normal size. If they are omitted, then the
default of 1.0 will be used, which means they are the same size as the line. For example, a value of 2.0 would
mean double normal size, and 0.5 would mean half normal size. If scaleFront and scaleBack are used, both
values must be supplied even when using EndCap.Front or EndCap.Back, and additionally both osets must
be supplied as well.
29
SetLine
static function SetLine (color : Color,
time : float = Mathf.Infinity,
params points : Vector2[] or Vector3[]) : VectorLine
Creates a VectorLine using the supplied points, and draws it immediately using the supplied color. The
points use screen-space coordinates if made with Vector2s, or world coordinates if made with Vector3s.
Params means that each point is supplied individually, rather than as an array. At least two Vector2s are
required; this will create a single line segment. Each additional Vector2 will extend the line to that point by
adding another line segment from the last. SetLine returns a VectorLine object, so it can be assigned to a
variable and used in any function that takes a VectorLine.
The optional time parameter specifies how long, in seconds, the line will be drawn before its destroyed. If
this is left out, the line will never be removed.
If Vector3 points are used and VectorLine.SetCamera3D has not been called, its called automatically the first
time SetLine is used, using the default parameters.
SetLine3D
static function SetLine3D (color : Color,
time : float = Mathf.Infinity,
params points : Vector3[]) : VectorLine
Creates a VectorLine using the supplied points, and draws it immediately using the supplied color. The
points use world-space coordinates. Params means that each point is supplied individually, rather than as
an array. At least two Vector3s are required; this will create a single line segment. Each additional Vector3 will
extend the line to that point by adding another line segment from the last. SetLine3D returns a VectorLine
object, so it can be assigned to a variable and used in any function that takes a VectorLine.
The lines created by SetLine3D are drawn in world space, rather than on top of other objects.
If VectorLine.SetCamera3D has not been called, its called automatically the first time SetLine3D is used,
using the default parameters.
30
SetRay
static function SetRay (color : Color,
time : float = Mathf.Infinity,
origin : Vector3,
direction : Vector3) : VectorLine
Creates a VectorLine from origin to origin + direction, and draws it immediately using the supplied color.
SetRay returns a VectorLine object, so it can be assigned to a variable and used in any function that takes a
VectorLine.
The optional time parameter specifies how long, in seconds, the line will be drawn before its destroyed. By
default, the line will never be removed.
If VectorLine.SetCamera3D has not been called, its called automatically the first time SetRay is used, using
the default parameters.
SetRay3D
static function SetRay3D (color : Color,
time : float = Mathf.Infinity,
origin : Vector3,
direction : Vector3) : VectorLine
Creates a VectorLine from origin to origin + direction, and draws it immediately using the supplied color.
The line is drawn in world space, rather than on top of other objects. SetRay3D returns a VectorLine object,
so it can be assigned to a variable and used in any function that takes a VectorLine.
The optional time parameter specifies how long, in seconds, the line will be drawn before its destroyed. If
this is left out, the line will never be removed.
If VectorLine.SetCamera3D has not been called, its called automatically the first time SetRay is used, using
the default parameters.
Version
static function Version () : String
VECTORMANAGER
31
GetBrightnessValue
static function GetBrightnessValue (position : Vector3) : float
Given the distance of position from the non-vector camera used in VectorLine.SetCamera, returns a float
between 0.0 and 1.0, where 0.0 is 0% brightness and 1.0 is 100% brightness.
ObjectSetup
static function ObjectSetup (gameObject
vectorLine
visibility
brightness
makeBounds
:
:
:
:
:
GameObject,
VectorLine,
Visibility,
Brightness,
boolean = true) : void
Makes gameObject have a shadow 3D vector object as defined by vectorLine, which behaves according
to the transform of gameObject. Depending on the values of visibility and brightness, one or more
components may be attached to gameObject when this function is called.
visibility can be Visibility.Dynamic, Visibility.Static, Visibility.Always, or Visibility.None. Visibility.Dynamic
causes the vector line to always be drawn when gameObject is visible to a camera, using the objects
transform. Visibility.Static only draws the vector line if the camera moves and the gameObject is visible to a
camera, and is for objects that never move, since the objects transform is only used once when the 3D
vector line is initialized. Visibility.Always causes the vector line to be drawn every frame and has no
optimizations. Visibility.None doesnt add any visibility components, and removes any Visibility scripts if
ObjectSetup has been called on this gameObject before.
brightness can be Brightness.Fog or Brightness.Normal. Brightness.Fog adds the BrightnessControl
component, which makes the 3D vector objects color behave according to the parameters given in
VectorManager.SetBrightnessParameters. If SetBrightnessParameters hasnt been called, the defaults for
that function will be used. Currently only the first color in the array is used for the entire object.
Brightness.None doesnt add any component, so the vector lines color wont be altered, and removes
BrightnessControl if ObjectSetup has been called on this gameObject before.
The optional makeBounds by default creates an invisible bounds mesh for the gameObjects mesh filter, so
that OnBecameInvisible and OnBecameInvisible will still work, which allows optimizations for
Visibility.Dynamic and Visibility.Static. If set to false, then the gameObjects mesh is not replaced by a
bounds mesh. One bounds mesh is created for each VectorLine name, so VectorLines that share a name will
also share a bounds mesh.
VECTORMANAGER
32
SetBrightnessParameters
static function SetBrightnessParameters (fadeOutDistance : float = 500,
fullBrightDistance : float = 250,
brightnessLevels : int = 32,
frequency : float = .2,
color : Color = Color.black) : void
Sets parameters for objects that use Brightness.Fog with VectorManager.ObjectSetup. fadeOutDistance is
the distance that the object must be from the camera to be completely faded out, or in other words have
100% fog color. fullBrightDistance is the distance that the object must be from the camera in order to
have the maximum amount (100%) of brightness. The VectorLines color will always be derived from
VectorLine.color even if other colors have been set with SetColor or SetColors.
The vector line will have brightnessLevels steps between 0% and 100% brightness. The fewer steps, the
more obvious the transitions become as the object moves closer and farther from the camera.
How often the distance of objects is checked depends on frequency, which by default is 5 times per second.
The color defines the fog color.
useDraw3D
var useDraw3D : bool = false