Fix: cleanup and minor perf improvements
This commit is contained in:
@@ -88,6 +88,9 @@ namespace Unheimlich.Core.Interaction
|
||||
|
||||
private void ResetSessionState()
|
||||
{
|
||||
// With Domain Reload disabled, static fields and per-instance flags persist between
|
||||
// Play Mode sessions. This method is called from OnEnable() to reset all transient
|
||||
// animation state so merged objects start fresh each session without needing a full reload.
|
||||
if (_isActive)
|
||||
{
|
||||
foreach (var word in _spawnedWords)
|
||||
@@ -107,17 +110,6 @@ namespace Unheimlich.Core.Interaction
|
||||
_hasCompletedMergeOnce = false; // reset so MergeOnce objects start fresh each session
|
||||
_currentConvergenceRadius = 0f;
|
||||
}
|
||||
|
||||
// Resets _hasCompletedMergeOnce at the very start of each Play Mode session so
|
||||
// merged objects start fresh without requiring a full Domain Reload.
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void OnPlayModeReset()
|
||||
{
|
||||
// Finding all instances isn't possible from a static context with SubsystemRegistration.
|
||||
// The reset is handled per-instance in OnEnable via _hasCompletedMergeOnce being
|
||||
// re-initialized when the scene reloads. For Enter Play Mode without scene reload,
|
||||
// ResetSessionState() is called from OnEnable and now correctly clears the flag.
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user