Saltar al contenido principal

3D Objects & Timers Reference

Label3D Object

Used to create text labels that exist in the 3D space, rather than as 2D UI overlays.

bool Visible

  • Description: Sets/Gets if the label 3D is visible.

string Text

  • Description: Sets the label text.

Vector3 Position

  • Description: Sets the label position in 3D space.

Color Color / Vector3 Color

  • Description: Sets the label color.

int Size

  • Description: Sets the label text size.

QuadCreator

Used to dynamically create a 3D plane (Quad mesh) where it is possible to modify its four vertices programmatically.

Color QuadColor / Material MaterialQuad

  • Description: Sets/Gets the plane color or material.

void SetTexture(string tx)

  • Description: Sets the passed texture name from the library.

void Transparent(float value)

  • Description: Sets the transparency value (0: opaque, 1: transparent).

void CreateQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, [Transform tr])

  • Description: Creates the plane with the specified vertex positions. Optionally, you can parent the quad to a component's transform.

void UpdateQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4)

  • Description: Updates the already created plane with new vertex positions.

MS Timers

Timers are extremely useful for programming sequences or delays without blocking the execution thread.

Tip

Using the built-in MS.Timers is the recommended way to handle delays as it simplifies your code and prevents logic errors.

void MS.SetTimer(string name, float interval)

  • Description: Starts a timer countdown called name with interval in milliseconds.

bool MS.GetTimer(string name)

  • Description: Returns true if the timer name has reached the countdown time.

void MS.ResetTimer(string name)

  • Description: Resets the specified timer.

Timer Examples

There are two ways to manage time in your scripts.

Approach 1: Using Time.deltaTime manually

float timer1;
float interval;
bool timerEnabled = false;

public void Init()
{
timer1 = 0;
interval = 5000; // in ms.
}

public void Main()
{
if(timerEnabled)
{
timer1 += Time.deltaTime * 1000;
if (timer1 >= interval)
{
timer1 = 0;
EditorUtils.ShowText("Timer Expired!");
timerEnabled = false;
}
}

if(Input.GetKeyDown(KeyCode.P))
{
EditorUtils.ShowText("");
timerEnabled = true;
}
}

Approach 2: Using the Built-in MS.Timers (Recommended)

public void Init()
{
// Initialization code
}

public void Main()
{
if(MS.GetTimer("Timer1"))
{
EditorUtils.ShowText("Timer Expired!");
MS.ResetTimer("Timer1");
}

if(Input.GetKeyDown(KeyCode.P))
{
EditorUtils.ShowText("");
MS.SetTimer("Timer1", 5000);
}
}