[Misc] Singleton pattern improvements, get rid of warnings and errors
This commit is contained in:
@@ -8,18 +8,20 @@ using UnityEngine.InputSystem;
|
||||
public class InputManager : MonoBehaviour
|
||||
{
|
||||
private static InputManager _instance;
|
||||
private static bool _isQuitting = false;
|
||||
|
||||
public static InputManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
if (_instance == null && Application.isPlaying && !_isQuitting)
|
||||
{
|
||||
_instance = FindAnyObjectByType<InputManager>();
|
||||
if (_instance == null)
|
||||
{
|
||||
var go = new GameObject("InputManager");
|
||||
_instance = go.AddComponent<InputManager>();
|
||||
DontDestroyOnLoad(go);
|
||||
// DontDestroyOnLoad(go);
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
@@ -36,7 +38,7 @@ public class InputManager : MonoBehaviour
|
||||
void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
// DontDestroyOnLoad(gameObject);
|
||||
playerInput = GetComponent<PlayerInput>();
|
||||
if (playerInput == null)
|
||||
{
|
||||
@@ -70,6 +72,11 @@ public class InputManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
_isQuitting = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the default ITouchInputConsumer to receive input events.
|
||||
/// </summary>
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Input
|
||||
private Vector2 lastHoldPosition;
|
||||
private Coroutine pathfindingDragCoroutine;
|
||||
private float pathfindingDragUpdateInterval = 0.1f; // Interval in seconds
|
||||
private bool pendingTap = false; // Track if OnHoldEnd is following a tap (legacy, see below)
|
||||
|
||||
// --- Unity/Component References ---
|
||||
private AIPath aiPath;
|
||||
@@ -254,8 +253,5 @@ namespace Input
|
||||
OnArrivedAtTarget?.Invoke();
|
||||
}
|
||||
}
|
||||
// --- Legacy/Unused fields ---
|
||||
// pendingTap: This field is not used in the current input flow. If you are not using tap/hold distinction logic elsewhere, consider removing it.
|
||||
// If you want to remove it, please confirm and I will do so.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user