Gizmo Square#
Description#
Displays a 2D square gizmo in the scene
Parameters#
| Name | Description |
|---|---|
| Mode | Whether to display a solid or a wireframe shape |
| Position | The position of the shape |
| Rotation | The rotation of the shape |
| Size | The width and height of the shape |
| Color | The color of the shape |
| Duration | The amount of seconds the shape will be displayed |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Gizmo Square")]
[Image(typeof(IconSquareSolid), ColorTheme.Type.Lime, typeof(Badge2D))]
[Description("Displays a 2D square gizmo in the scene")]
[Category("Debug/Gizmos/Square")]
[Parameter("Mode", "Whether to display a solid or a wireframe shape")]
[Parameter("Position", "The position of the shape")]
[Parameter("Rotation", "The rotation of the shape")]
[Parameter("Size", "The width and height of the shape")]
[Parameter("Color", "The color of the shape")]
[Parameter("Duration", "The amount of seconds the shape will be displayed")]
[Keywords("Draw", "Debug", "Gizmo", "Rectangle", "Quad", "2D")]
[Serializable]
public class InstructionCoreDebugGizmoSquare : Instruction
{
[SerializeField] private GizmoMode m_Mode = GizmoMode.Outline;
[SerializeField] private GetVector3 m_Position = new GetVector3();
[SerializeField] private GetQuaternion m_Rotation = new GetQuaternion();
[SerializeField] private GetVector2 m_Size = new GetVector2(Vector2.one);
[SerializeField] private GetColor m_Color = new GetColor(Color.green.SetAlpha(0.5f));
[SerializeField] private GetNumber m_Duration = new GetNumber(1f);
protected override string GetTitle(GameObject source) => $"Display {this.m_Mode} Square at {this.m_Position}";
protected override Awaitable Run(Args args)
{
GizmosManager.Square(
this.m_Position.Get(args),
this.m_Rotation.Get(args),
this.m_Size.Get(args),
this.m_Color.Get(args),
this.m_Mode,
this.m_Duration.GetFloat(args)
);
return Done;
}
}
}