Gizmo Mesh#
Description#
Displays a mesh gizmo in the scene
Parameters#
| Name | Description |
|---|---|
| Mode | Whether to display a solid or a wireframe mesh |
| Mesh | The mesh asset to display |
| Position | The position of the mesh |
| Rotation | The rotation of the mesh |
| Scale | The scale of the mesh |
| Color | The color of the mesh |
| Duration | The amount of seconds the mesh will be displayed |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Gizmo Mesh")]
[Image(typeof(IconMesh), ColorTheme.Type.Lime)]
[Description("Displays a mesh gizmo in the scene")]
[Category("Debug/Gizmos/Mesh")]
[Parameter("Mode", "Whether to display a solid or a wireframe mesh")]
[Parameter("Mesh", "The mesh asset to display")]
[Parameter("Position", "The position of the mesh")]
[Parameter("Rotation", "The rotation of the mesh")]
[Parameter("Scale", "The scale of the mesh")]
[Parameter("Color", "The color of the mesh")]
[Parameter("Duration", "The amount of seconds the mesh will be displayed")]
[Keywords("Draw", "Debug", "Gizmo", "Model")]
[Serializable]
public class InstructionCoreDebugGizmoMesh : Instruction
{
[SerializeField] private GizmoMode m_Mode = GizmoMode.Outline;
[SerializeField] private Mesh m_Mesh;
[SerializeField] private GetVector3 m_Position = new GetVector3();
[SerializeField] private GetQuaternion m_Rotation = new GetQuaternion();
[SerializeField] private GetVector3 m_Scale = new GetVector3(Vector3.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} Mesh at {this.m_Position}";
protected override Awaitable Run(Args args)
{
if (this.m_Mesh == null) return Done;
GizmosManager.Mesh(
this.m_Mesh,
this.m_Position.Get(args),
this.m_Rotation.Get(args),
this.m_Scale.Get(args),
this.m_Color.Get(args),
this.m_Mode,
this.m_Duration.GetFloat(args)
);
return Done;
}
}
}