NodeCanvas Forums › Support › Nested FSM in nested BT never stops › Reply To: Nested FSM in nested BT never stops
Hello,
Sorry for late reply.
It’s a bug that has beed fixed.
Please replace the contents of MonoManager.cs with the following code and let me know if it’s solved for you.
Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
using System.Collections.Generic; using System; using UnityEngine; namespace ParadoxNotion.Services { ///Singleton. Automatically added when needed, collectively calls methods that needs updating amongst other things relative to MonoBehaviours public class MonoManager : MonoBehaviour { public event Action onUpdate; public event Action onLateUpdate; public event Action onFixedUpdate; public event Action onGUI; private List<Action> onUpdateCalls = new List<Action>(); private List<Action> onLateUpdateCalls = new List<Action>(); private List<Action> onFixedUpdateCalls = new List<Action>(); private List<Action> onGUICalls = new List<Action>(); private static bool isQuiting; private static MonoManager _current; public static MonoManager current { get { if ( _current == null && !isQuiting ) { _current = FindObjectOfType<MonoManager>(); if ( _current == null ) _current = new GameObject("_MonoManager").AddComponent<MonoManager>(); } return _current; } } ///Creates MonoManager singleton public static void Create() { _current = current; } public static void AddUpdateMethod(Action method) { current.onUpdateCalls.Add(method); } public static void RemoveUpdateMethod(Action method) { current.onUpdateCalls.Remove(method); } public static void AddLateUpdateMethod(Action method) { current.onLateUpdateCalls.Add(method); } public static void RemoveLateUpdateMethod(Action method) { current.onLateUpdateCalls.Remove(method); } public static void AddFixedUpdateMethod(Action method) { current.onFixedUpdateCalls.Add(method); } public static void RemoveFixedUpdateMethod(Action method) { current.onFixedUpdateCalls.Remove(method); } public static void AddOnGUIMethod(Action method) { current.onGUICalls.Add(method); } public static void RemoveOnGUIMethod(Action method) { current.onGUICalls.Remove(method); } void Awake() { if ( _current != null && _current != this ) { DestroyImmediate(this.gameObject); return; } DontDestroyOnLoad(gameObject); _current = this; } void OnApplicationQuit() { isQuiting = true; } void Update(){ for (var i = 0; i < onUpdateCalls.Count; i++){ onUpdateCalls<em class="d4pbbc-italic"></em>(); } if (onUpdate != null){ onUpdate(); } } void LateUpdate(){ for (var i = 0; i < onLateUpdateCalls.Count; i++){ onLateUpdateCalls<em class="d4pbbc-italic"></em>(); } if (onLateUpdate != null){ onLateUpdate(); } } void FixedUpdate(){ for (var i = 0; i < onFixedUpdateCalls.Count; i++){ onFixedUpdateCalls<em class="d4pbbc-italic"></em>(); } if (onFixedUpdate != null){ onFixedUpdate(); } } void OnGUI(){ for (var i = 0; i < onGUICalls.Count; i++){ onGUICalls<em class="d4pbbc-italic"></em>(); } if (onGUI != null){ onGUI(); } } } } |
Join us on Discord: https://discord.gg/97q2Rjh