Skip to content

Commit

Permalink
fix: editor crashed on exit play mode (editor, windows)
Browse files Browse the repository at this point in the history
close #351
  • Loading branch information
mob-sakai committed Jan 7, 2025
1 parent 1b01103 commit 47ee45c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Packages/src/Runtime/UIParticleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,26 @@ public static void Unregister(UIParticleAttractor attractor)

#if UNITY_EDITOR
[InitializeOnLoadMethod]
private static void InitializeOnLoad()
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;

EditorApplication.playModeStateChanged += state =>
{
UIExtraCallbacks.onAfterCanvasRebuild -= Refresh;
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.EnteredPlayMode)
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;
}
};
}
#else
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
private static void InitializeOnLoad()
{
UIExtraCallbacks.onAfterCanvasRebuild += Refresh;
}
#endif

private static void Refresh()
{
Expand Down

0 comments on commit 47ee45c

Please sign in to comment.