fix: support "disable domain reload" on Unity 6.6 or later

This commit is contained in:
mob-sakai
2026-06-28 13:28:24 +09:00
parent 16ab8d7bb8
commit e19638f0ec
3 changed files with 12 additions and 31 deletions

View File

@@ -18,12 +18,6 @@ namespace Coffee.UIParticleInternal
private static readonly FastAction s_OnScreenSizeChangedAction = new FastAction();
private static Vector2Int s_LastScreenSize;
static UIExtraCallbacks()
{
Canvas.willRenderCanvases += OnBeforeCanvasRebuild;
Logger.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
}
/// <summary>
/// Event that occurs after canvas rebuilds.
/// </summary>
@@ -72,7 +66,7 @@ namespace Coffee.UIParticleInternal
CanvasUpdateRegistry.IsRebuildingLayout();
#if TMP_ENABLE
// Explicitly set `Canvas.willRenderCanvases += TMP_UpdateManager.DoRebuilds`.
typeof(TMPro.TMP_UpdateManager)
var _ = typeof(TMPro.TMP_UpdateManager)
.GetProperty("instance", BindingFlags.NonPublic | BindingFlags.Static)
.GetValue(null);
#endif
@@ -83,6 +77,7 @@ namespace Coffee.UIParticleInternal
}
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
[InitializeOnLoadMethod]
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
#elif UNITY_EDITOR
[InitializeOnLoadMethod]
@@ -91,9 +86,17 @@ namespace Coffee.UIParticleInternal
#endif
private static void InitializeOnLoad()
{
#if UNITY_2019_4 || UNITY_2020_2_OR_NEWER
Canvas.preWillRenderCanvases -= OnBeforeCanvasRebuild;
Canvas.preWillRenderCanvases += OnBeforeCanvasRebuild;
#else
Canvas.willRenderCanvases -= OnBeforeCanvasRebuild;
Canvas.willRenderCanvases += OnBeforeCanvasRebuild;
#endif
Canvas.willRenderCanvases -= OnAfterCanvasRebuild;
s_IsInitializedAfterCanvasRebuild = false;
s_LastScreenSize = default;
Logger.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
}
/// <summary>