Files
AppleHillsProduction/Assets/Editor/TrenchTileSpawnerEditor.cs
2025-09-22 10:55:45 +02:00

43 lines
1.5 KiB
C#

using UnityEditor;
using UnityEngine;
using Minigames.DivingForPictures;
/// <summary>
/// Custom editor for TrenchTileSpawner that adds a runtime button to test the StartSurfacing function
/// </summary>
[CustomEditor(typeof(TrenchTileSpawner))]
public class TrenchTileSpawnerEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
// Draw the default inspector
DrawDefaultInspector();
// Get the target TrenchTileSpawner
TrenchTileSpawner spawner = (TrenchTileSpawner)target;
// Add space between default inspector and custom button
EditorGUILayout.Space(10);
// Separator line
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
// Add a label for the runtime testing section
EditorGUILayout.LabelField("Runtime Testing", EditorStyles.boldLabel);
// Only enable the button during play mode
EditorGUI.BeginDisabledGroup(!Application.isPlaying);
// Add the button to call StartSurfacing
if (GUILayout.Button("Start Surfacing", GUILayout.Height(30)))
{
spawner.StartSurfacing();
}
EditorGUI.EndDisabledGroup();
// Add explanatory text
EditorGUILayout.HelpBox("This button will reverse the direction of the trench movement, making the player surface instead of descend. Only works in Play Mode.", MessageType.Info);
}
}