Files
2026-03-04 09:37:33 +08:00

84 lines
1.7 KiB
C#

using UnityEngine;
namespace DebuggingEssentials
{
[ConsoleAlias("test")]
public class TestConsole : MonoBehaviour
{
private enum TestMode
{
ModeA = 0,
ModeB = 1,
ModeC = 2
}
private delegate float DoMath(float a, float b);
[ConsoleCommand("fields.", "", AccessLevel.Admin)]
private float testValue1 = 10.23f;
[ConsoleCommand("fields.", "This is testMode", AccessLevel.Admin)]
private TestMode testMode = TestMode.ModeB;
[ConsoleCommand("fields.testValue3Override", "This is testValue3", AccessLevel.Admin)]
private float testValue3 = 15f;
[ConsoleCommand("fields.", "This is a test position", AccessLevel.Admin)]
private Vector3 position;
private int testProp2;
[ConsoleCommand("delegate.", "", AccessLevel.Admin)]
private DoMath doMath;
[ConsoleCommand("props.AAA", "", AccessLevel.Admin)]
private bool AutoProp1 { get; set; }
[ConsoleCommand("props.", "This is testProp1", AccessLevel.Admin)]
public int TestProp2
{
get
{
return testProp2;
}
set
{
testProp2 = value;
}
}
private void Awake()
{
RuntimeConsole.Register(this);
doMath = Multiply;
}
private void OnDestroy()
{
RuntimeConsole.Unregister(this);
}
[ConsoleCommand("methods.", "", AccessLevel.Admin)]
private void PrintHello()
{
Debug.Log("Hello!");
}
[ConsoleCommand("methods.", "Print x amount of numbers", AccessLevel.Admin)]
private int PrintNumbers(int count)
{
for (int i = 0; i < count; i++)
{
RuntimeConsole.Log("number " + i, new Color((float)i / 255f % 1f, 1f, 0f), showConsole: true);
}
return count;
}
[ConsoleCommand("methods.", "", AccessLevel.Admin)]
private float Multiply(float a, float b)
{
return a * b;
}
}
}