diff --git a/CHANGELOG.md b/CHANGELOG.md
index b225d53..6218173 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,31 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.9.2] - 2024-10-25
+
+**Fixed**
+- Changed the try/catch exceptions to Debug.LogException with a Debug.LogError, to properly show the issues in the Unity console
+
+## [0.9.1] - 2023-09-04
+
+**Fixed**
+- Added missing documentation to describe the purpose of the *InnerStateData* and *StateFactoryData* classes.
+
+## [0.9.0] - 2023-09-02
+
+- Introduced unique identifiers for *IWaitActivity* instances to differentiate between different activities
+- Enhanced the *TaskWaitState* class with a new event queuing mechanism to handle events after task completion
+- Improved the *SplitState* class to allow pausing/resuming of inner state transitions
+
+**Changed**
+- Updated exception handling across various classes, replacing *MissingMemberException* with *InvalidOperationException* for more appropriate error representation
+
+## [0.8.0] - 2023-08-03
+
+**Changed**
+- Change the main class name from *Statemachine* to *Statechart* Change namespace to avoid conflicts to StatechartMachine
+- Changed both *ISplitState* and *INestedState* to receive a single parameterized *NestedStateData* to make calls less verbose and ready for future scalability
+
## [0.7.0] - 2021-05-04
- Improved State documentations
diff --git a/Runtime/Internal/StateInternal.cs b/Runtime/Internal/StateInternal.cs
index 83c5fa4..2116a8b 100644
--- a/Runtime/Internal/StateInternal.cs
+++ b/Runtime/Internal/StateInternal.cs
@@ -164,7 +164,14 @@ private void TriggerEnter(IStateInternal state)
}
catch (Exception e)
{
- throw new Exception($"Exception in the state {state.Name}, OnEnter() actions.\n" + CreationStackTrace, e);
+ var finalMessage = "";
+#if UNITY_EDITOR || DEBUG
+ finalMessage = $"\nStackTrace log of '{state.Name}' state creation bellow.\n{CreationStackTrace}";
+#endif
+
+ Debug.LogError($"Exception in the state '{state.Name}', OnExit() actions.\n" +
+ $"-->> Check the exception log after this one for more details <<-- {finalMessage}");
+ Debug.LogException(e);
}
}
@@ -180,7 +187,14 @@ private void TriggerExit()
}
catch(Exception e)
{
- throw new Exception($"Exception in the state '{Name}', OnExit() actions.\n" + CreationStackTrace, e);
+ var finalMessage = "";
+#if UNITY_EDITOR || DEBUG
+ finalMessage = $"\nStackTrace log of '{Name}' state creation bellow.\n{CreationStackTrace}";
+#endif
+
+ Debug.LogError($"Exception in the state '{Name}', OnExit() actions.\n" +
+ $"-->> Check the exception log after this one for more details <<-- {finalMessage}");
+ Debug.LogException(e);
}
}
@@ -199,8 +213,14 @@ private void TriggerTransition(ITransitionInternal transition, string eventName)
}
catch (Exception e)
{
- throw new Exception($"Exception in the transition '{Name}' -> '{transition.TargetState?.Name}'," +
- $" TriggerTransition() actions.\n{transition.CreationStackTrace}", e);
+ var finalMessage = "";
+#if UNITY_EDITOR || DEBUG
+ finalMessage = $"\nStackTrace log of this transition creation bellow.\n{transition.CreationStackTrace}";
+#endif
+
+ Debug.LogError($"Exception in the transition '{Name}' -> '{transition.TargetState?.Name}'" +
+ $"-->> Check the exception log after this one for more details <<-- {finalMessage}");
+ Debug.LogException(e);
}
}
}
diff --git a/Runtime/Internal/TaskWaitState.cs b/Runtime/Internal/TaskWaitState.cs
index acf4e41..ddab3db 100644
--- a/Runtime/Internal/TaskWaitState.cs
+++ b/Runtime/Internal/TaskWaitState.cs
@@ -143,8 +143,15 @@ private async Task InnerTaskAwait(string eventName)
}
catch (Exception e)
{
- throw new Exception($"Exception in the state '{Name}', when calling the task wait action " +
- $"'{_taskAwaitAction.Target}.{_taskAwaitAction.Method.Name}()'.\n" + CreationStackTrace, e);
+ var finalMessage = "";
+#if UNITY_EDITOR || DEBUG
+ finalMessage = $"\nStackTrace log of '{Name}' state creation bellow.\n{CreationStackTrace}";
+#endif
+
+ Debug.LogError($"Exception in the state '{Name}', when calling the task wait action" +
+ $"'{_taskAwaitAction.Target}.{_taskAwaitAction.Method.Name}()'.\n" +
+ $"-->> Check the exception log after this one for more details <<-- {finalMessage}");
+ Debug.LogException(e);
}
}
}
diff --git a/Runtime/Internal/WaitState.cs b/Runtime/Internal/WaitState.cs
index 94983b4..62331e9 100644
--- a/Runtime/Internal/WaitState.cs
+++ b/Runtime/Internal/WaitState.cs
@@ -39,7 +39,7 @@ public override void Enter()
_waitingActivity = new WaitActivity(OnActivityComplete);
_triggered = false;
- for(int i = 0; i < _onEnter.Count; i++)
+ for (int i = 0; i < _onEnter.Count; i++)
{
_onEnter[i]?.Invoke();
}
@@ -48,7 +48,7 @@ public override void Enter()
///
public override void Exit()
{
- for(int i = 0; i < _onExit.Count; i++)
+ for (int i = 0; i < _onExit.Count; i++)
{
_onExit[i]?.Invoke();
}
@@ -132,7 +132,7 @@ public ITransition WaitingFor(Action waitAction)
private void OnActivityComplete(uint id)
{
- if(id == _waitingActivity.Id)
+ if (id == _waitingActivity.Id)
{
_stateFactory.Data.StateChartMoveNextCall(null);
}
@@ -143,7 +143,7 @@ protected override ITransitionInternal OnTrigger(IStatechartEvent statechartEven
{
if (statechartEvent != null && _events.TryGetValue(statechartEvent, out var transition))
{
- if(transition.TargetState != null)
+ if (transition.TargetState != null)
{
_waitingActivity.ForceComplete();
}
@@ -167,14 +167,21 @@ private void InnerWait(string eventName)
if (IsStateLogsEnabled)
{
Debug.Log($"'{eventName}' event triggers the wait method '{_waitAction.Method.Name}'" +
- $"from the object {_waitAction.Target} in the state {Name}");
+ $"from the object {_waitAction.Target} in the state {Name}");
}
_waitAction(_waitingActivity);
}
- catch(Exception e)
+ catch (Exception e)
{
- throw new Exception($"Exception in the state '{Name}', when calling the wait action {_waitAction.Method.Name}" +
- $"from the object {_waitAction.Target}.\n" + CreationStackTrace, e);
+ var finalMessage = "";
+#if UNITY_EDITOR || DEBUG
+ finalMessage = $"\nStackTrace log of '{Name}' state creation bellow.\n{CreationStackTrace}";
+#endif
+
+ Debug.LogError($"Exception in the state '{Name}', when calling the wait action {_waitAction.Method.Name}" +
+ $" from the object {_waitAction.Target}.\n" +
+ $"-->> Check the exception log after this one for more details <<-- {finalMessage}");
+ Debug.LogException(e);
}
}
}
diff --git a/package.json b/package.json
index db590cc..337d731 100644
--- a/package.json
+++ b/package.json
@@ -2,8 +2,8 @@
"name": "com.gamelovers.statechart",
"displayName": "Statechart",
"author": "Miguel Tomas",
- "version": "0.9.1",
- "unity": "2021.4",
+ "version": "0.9.2",
+ "unity": "2022.4",
"license": "MIT",
"description": "This package allows the use of Statecharts (Hierarchichal State Machine) within an Unity project.\n\nThe primary feature of Statecharts is that states can be organized in a hierarchy.\nA Statecharts is a state machine where each state in the state machine may define its own subordinate state machines, called substates.\nThose states can again define substates.\n\nFor more information: https://statecharts.github.io/what-is-a-statechart.html",
"type": "library",