Files
Stair_Horror/Assets/Scripts/DebugControlPanel.cs

109 lines
3.0 KiB
C#

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor; // Required for the buttons to appear
#endif
public class DebugControlPanel : MonoBehaviour
{
[Header("Target Scripts")]
public FrontDoorEvent frontDoorScript;
public StairWarp stairWarpScript;
// We don't need to drag in GameManager since it's a Singleton (GameManager.Instance)
[Header("Status")]
public string lastAction = "None";
// --- HELPER FUNCTIONS FOR THE BUTTONS ---
public void TestDoorbell()
{
if (frontDoorScript != null)
{
frontDoorScript.TriggerEvent();
lastAction = "Triggered Doorbell Sequence";
}
else Debug.LogError("Front Door Script not assigned!");
}
public void TestNightmare()
{
if (GameManager.Instance != null)
{
GameManager.Instance.TriggerNightmareMode();
lastAction = "Triggered Nightmare Mode";
}
else Debug.LogError("GameManager not found!");
}
public void ForceWarp()
{
// Note: You must change 'WarpPlayer' to PUBLIC in StairWarp.cs for this to work
if (stairWarpScript != null)
{
// We pass the player object to the warp script manually for testing
GameObject player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
// Assuming you changed WarpPlayer to public, otherwise this line errors
stairWarpScript.WarpPlayer(player);
lastAction = "Forced Stair Warp";
}
}
}
public void ToggleAllLights()
{
if (GameManager.Instance != null)
{
foreach (LightSwitch sw in GameManager.Instance.allSwitches)
{
sw.Interact(); // Manually click every switch
}
lastAction = "Toggled All Lights";
}
}
}
// --- THE EDITOR MAGIC ---
// This part tells Unity how to draw the inspector for this specific script
#if UNITY_EDITOR
[CustomEditor(typeof(DebugControlPanel))]
public class DebugControlPanelEditor : Editor
{
public override void OnInspectorGUI()
{
// Draw the default variables (the slots to drag scripts into)
DrawDefaultInspector();
// Get reference to the script
DebugControlPanel myScript = (DebugControlPanel)target;
GUILayout.Space(20); // Add some spacing
GUILayout.Label("Event Triggers", EditorStyles.boldLabel);
// Draw Buttons
if (GUILayout.Button("Trigger Doorbell Event"))
{
myScript.TestDoorbell();
}
if (GUILayout.Button("Trigger Nightmare Mode"))
{
myScript.TestNightmare();
}
if (GUILayout.Button("Toggle All Lights"))
{
myScript.ToggleAllLights();
}
GUILayout.Space(10);
if (GUILayout.Button("Force Warp Player"))
{
myScript.ForceWarp();
}
}
}
#endif