| | | 1 | | using UnityEngine; |
| | | 2 | | |
| | | 3 | | // The early fixed update manager allows actions to be executed before the main fixed update call |
| | | 4 | | // due to its position in the script execution order. |
| | | 5 | | [DefaultExecutionOrder(-50)] |
| | | 6 | | public class EarlyFixedUpdateManager : MonoBehaviour { |
| | | 7 | | // Simulation events. |
| | | 8 | | public delegate void UpdateHandler(); |
| | | 9 | | public event UpdateHandler OnEarlyFixedUpdate; |
| | | 10 | | |
| | 7668 | 11 | | public static EarlyFixedUpdateManager Instance { get; private set; } |
| | | 12 | | |
| | 1 | 13 | | private void Awake() { |
| | 1 | 14 | | if (Instance != null && Instance != this) { |
| | 0 | 15 | | Destroy(gameObject); |
| | 0 | 16 | | return; |
| | | 17 | | } |
| | 1 | 18 | | Instance = this; |
| | 1 | 19 | | DontDestroyOnLoad(gameObject); |
| | 1 | 20 | | } |
| | | 21 | | |
| | 104 | 22 | | private void FixedUpdate() { |
| | 104 | 23 | | OnEarlyFixedUpdate?.Invoke(); |
| | 104 | 24 | | } |
| | | 25 | | } |