Added Observation Scene to show the Replay

This commit is contained in:
Thorbjoern
2025-05-26 18:56:25 +02:00
parent 37c6bd8269
commit c304bc0e10
211 changed files with 60070 additions and 14 deletions
@@ -0,0 +1,57 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Unity.Cinemachine.Samples
{
public class CursorLockManager : MonoBehaviour, Unity.Cinemachine.IInputAxisOwner
{
public InputAxis CursorLock = InputAxis.DefaultMomentary;
public UnityEvent OnCursorLocked = new ();
public UnityEvent OnCursorUnlocked = new ();
bool m_IsTriggered;
public void GetInputAxes(List<IInputAxisOwner.AxisDescriptor> axes)
{
axes.Add(new()
{
DrivenAxis = () => ref CursorLock, Name = "CursorLock",
Hint = IInputAxisOwner.AxisDescriptor.Hints.X
});
}
void OnEnable() => UnlockCursor();
void OnDisable() => UnlockCursor();
void Update()
{
if (CursorLock.Value == 0)
m_IsTriggered = false;
else if (!m_IsTriggered)
{
m_IsTriggered = true;
if (Cursor.lockState == CursorLockMode.None)
LockCursor();
else
UnlockCursor();
}
}
public void LockCursor()
{
if (enabled)
{
Cursor.lockState = CursorLockMode.Locked;
OnCursorLocked.Invoke();
}
}
public void UnlockCursor()
{
Cursor.lockState = CursorLockMode.None;
OnCursorUnlocked.Invoke();
}
}
}