Files

30 lines
895 B
C#
Raw Permalink Normal View History

2025-04-18 15:54:50 -04:00
using UnityEngine;
using Game;
using Music;
using Player;
using UnityEngine.EventSystems;
2025-04-16 19:57:54 -04:00
namespace Game
{
2025-04-18 15:54:50 -04:00
/// <summary>
/// This class makes sure there is only one EventSystem in the game at any time.
/// </summary>
public class EventSystemizer : MonoBehaviour
{
2025-04-18 15:54:50 -04:00
/// <summary>
/// Checks every frame to ensure there is only one EventSystem in the game.
/// </summary>
private void Update()
{
2025-04-18 15:54:50 -04:00
// Find all EventSystem objects in the scene
foreach (EventSystem system in FindObjectsByType<EventSystem>(FindObjectsSortMode.None))
{
// Skip the EventSystem attached to this GameObject
if (system == GetComponent<EventSystem>()) continue;
// Remove any extra EventSystem objects
Destroy(system.gameObject);
}
}
}
2025-04-16 19:57:54 -04:00
}