From d0cda9d12d9667e3bc0721c80458be28966a585a Mon Sep 17 00:00:00 2001 From: Oliver Biwer Date: Mon, 24 Jul 2023 19:09:00 +0200 Subject: [PATCH] fix: FSM not compatible with disabled domain reload (#402) --- Packages/Core/Runtime/Variables/AtomVariable.cs | 2 +- .../FSM/Runtime/FiniteStateMachine/FiniteStateMachine.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/Core/Runtime/Variables/AtomVariable.cs b/Packages/Core/Runtime/Variables/AtomVariable.cs index 81f88449..03ea9371 100644 --- a/Packages/Core/Runtime/Variables/AtomVariable.cs +++ b/Packages/Core/Runtime/Variables/AtomVariable.cs @@ -138,7 +138,7 @@ private void OnValidate() _value = RunPreChangeTransformers(_value); } - private void OnEnable() + protected virtual void OnEnable() { SetInitialValues(); TriggerInitialEvents(); diff --git a/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachine.cs b/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachine.cs index bf8ff0e2..3b23f2e4 100644 --- a/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachine.cs +++ b/Packages/FSM/Runtime/FiniteStateMachine/FiniteStateMachine.cs @@ -1,4 +1,5 @@ using System; +using System.Transactions; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; @@ -64,8 +65,10 @@ public override string Value /// private string _currentFlatValue; - private void OnEnable() + protected override void OnEnable() { + base.OnEnable(); // handles resetting and initial values and all that. + if (CompleteCurrentTransition != null && CompleteCurrentTransition.ReplayBufferSize > 0) { Debug.LogWarning("The Complete Current Transition event had a replay buffer size great than 0, which would cause unwanted behaviour. Setting it to 0 in order to avoid unexpected behaviour.");