Added comments to everything
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
using UnityEngine; using Game; using Music; using Player;
|
||||
using UnityEngine;
|
||||
using Game;
|
||||
using Music;
|
||||
using Player;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public class EventSystemizer : MonoBehaviour
|
||||
{
|
||||
private void Update() // Ensures only one instance of EventSystem exists
|
||||
/// <summary>
|
||||
/// This class makes sure there is only one EventSystem in the game at any time.
|
||||
/// </summary>
|
||||
public class EventSystemizer : MonoBehaviour
|
||||
{
|
||||
foreach (EventSystem system in FindObjectsByType<EventSystem>(FindObjectsSortMode.None))
|
||||
/// <summary>
|
||||
/// Checks every frame to ensure there is only one EventSystem in the game.
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (system == GetComponent<EventSystem>()) continue;
|
||||
Destroy(system.gameObject);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user