Vectrosity Demo: Selection Box

Here’s a complete script example of a selection box using Vectrosity. It uses the uniform-scaled texture functionality for animated dashed lines. Try it now, by dragging out a box below.

import System.Collections.Generic;
import Vectrosity;

var lineTexture : Texture;
var textureScale = 4.0;
private var selectionLine : VectorLine;
private var originalPos : Vector2;

function Start () {
    selectionLine = new VectorLine("Selection", new List.<Vector2>(5), lineTexture, 4.0, LineType.Continuous);
    selectionLine.textureScale = textureScale;
}

function OnGUI () {
    GUI.Label(Rect(10, 10, 300, 25), "Click & drag to make a selection box");
}

function Update () {
    if (Input.GetMouseButtonDown(0)) {
        originalPos = Input.mousePosition;
    }
    if (Input.GetMouseButton(0)) {
        selectionLine.MakeRect (originalPos, Input.mousePosition);
        selectionLine.Draw();
    }
    selectionLine.textureOffset = -Time.time*2.0 % 1;
}

Get Vectrosity now >