From 48b38ec34fc804a42e2219c475578a2ca6b5360c Mon Sep 17 00:00:00 2001
From: mob-sakai <12690315+mob-sakai@users.noreply.github.com>
Date: Mon, 8 Jun 2026 13:27:27 +0900
Subject: [PATCH] update internal code
---
Packages/src/Runtime/AnimatableProperty.cs | 28 +++----------------
.../Extensions/ComponentExtensions.cs | 2 +-
.../PreloadedProjectSettings.cs | 2 ++
.../Utilities/{Logging.cs => Logger.cs} | 2 +-
.../Runtime/Internal/Utilities/Logger.cs.meta | 2 ++
.../Internal/Utilities/Logging.cs.meta | 11 --------
.../src/Runtime/Internal/Utilities/Misc.cs | 2 +-
.../Runtime/Internal/Utilities/ObjectPool.cs | 8 +++---
.../Internal/Utilities/ObjectRepository.cs | 10 +++----
.../Internal/Utilities/UIExtraCallbacks.cs | 13 +++++++--
10 files changed, 31 insertions(+), 49 deletions(-)
rename Packages/src/Runtime/Internal/Utilities/{Logging.cs => Logger.cs} (99%)
create mode 100644 Packages/src/Runtime/Internal/Utilities/Logger.cs.meta
delete mode 100644 Packages/src/Runtime/Internal/Utilities/Logging.cs.meta
diff --git a/Packages/src/Runtime/AnimatableProperty.cs b/Packages/src/Runtime/AnimatableProperty.cs
index 2793395..b0b892a 100644
--- a/Packages/src/Runtime/AnimatableProperty.cs
+++ b/Packages/src/Runtime/AnimatableProperty.cs
@@ -37,37 +37,17 @@ namespace Coffee.UIExtensions
switch (type)
{
case ShaderPropertyType.Color:
- var color = mpb.GetColor(id);
- if (color != default)
- {
- material.SetColor(id, color);
- }
-
+ material.SetColor(id, mpb.GetColor(id));
break;
case ShaderPropertyType.Vector:
- var vector = mpb.GetVector(id);
- if (vector != default)
- {
- material.SetVector(id, vector);
- }
-
+ material.SetVector(id, mpb.GetVector(id));
break;
case ShaderPropertyType.Float:
case ShaderPropertyType.Range:
- var value = mpb.GetFloat(id);
- if (!Mathf.Approximately(value, 0))
- {
- material.SetFloat(id, value);
- }
-
+ material.SetFloat(id, mpb.GetFloat(id));
break;
case ShaderPropertyType.Texture:
- var tex = mpb.GetTexture(id);
- if (tex != default(Texture))
- {
- material.SetTexture(id, tex);
- }
-
+ material.SetTexture(id, mpb.GetTexture(id));
break;
}
}
diff --git a/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs b/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs
index 82314bf..e95c5f6 100644
--- a/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs
+++ b/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs
@@ -184,7 +184,7 @@ namespace Coffee.UIParticleInternal
///
/// Verify whether it can be converted to the specified component.
///
- internal static bool CanConvertTo(this Object context) where T : MonoBehaviour
+ internal static bool CanConvertTo(this Object context) where T : MonoBehaviour
{
return context != null && context.GetType() != typeof(T);
}
diff --git a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs
index 2f469cb..fd09928 100644
--- a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs
+++ b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs
@@ -158,6 +158,8 @@ namespace Coffee.UIParticleInternal
private void OnPlayModeStateChanged(PlayModeStateChange state)
{
+ if (!this) return;
+
switch (state)
{
case PlayModeStateChange.ExitingEditMode:
diff --git a/Packages/src/Runtime/Internal/Utilities/Logging.cs b/Packages/src/Runtime/Internal/Utilities/Logger.cs
similarity index 99%
rename from Packages/src/Runtime/Internal/Utilities/Logging.cs
rename to Packages/src/Runtime/Internal/Utilities/Logger.cs
index 12c5b79..ef8593a 100644
--- a/Packages/src/Runtime/Internal/Utilities/Logging.cs
+++ b/Packages/src/Runtime/Internal/Utilities/Logger.cs
@@ -11,7 +11,7 @@ using Conditional = System.Diagnostics.ConditionalAttribute;
namespace Coffee.UIParticleInternal
{
- internal static class Logging
+ internal static class Logger
{
#if !ENABLE_COFFEE_LOGGER
private const string k_DisableSymbol = "DISABLE_COFFEE_LOGGER";
diff --git a/Packages/src/Runtime/Internal/Utilities/Logger.cs.meta b/Packages/src/Runtime/Internal/Utilities/Logger.cs.meta
new file mode 100644
index 0000000..5ce2425
--- /dev/null
+++ b/Packages/src/Runtime/Internal/Utilities/Logger.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 4f9f22bb079324476b1473030ad9fec3
\ No newline at end of file
diff --git a/Packages/src/Runtime/Internal/Utilities/Logging.cs.meta b/Packages/src/Runtime/Internal/Utilities/Logging.cs.meta
deleted file mode 100644
index 6db7856..0000000
--- a/Packages/src/Runtime/Internal/Utilities/Logging.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 8255313895da84e7cbdc876be3795334
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Packages/src/Runtime/Internal/Utilities/Misc.cs b/Packages/src/Runtime/Internal/Utilities/Misc.cs
index 353abe6..b6654cc 100644
--- a/Packages/src/Runtime/Internal/Utilities/Misc.cs
+++ b/Packages/src/Runtime/Internal/Utilities/Misc.cs
@@ -20,7 +20,7 @@ namespace Coffee.UIParticleInternal
{
public static T[] FindObjectsOfType() where T : Object
{
-#if UNITY_6000_5_OR_NEWER
+#if UNITY_6000_4_OR_NEWER
return Object.FindObjectsByType(FindObjectsInactive.Include);
#elif UNITY_2023_1_OR_NEWER
return Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None);
diff --git a/Packages/src/Runtime/Internal/Utilities/ObjectPool.cs b/Packages/src/Runtime/Internal/Utilities/ObjectPool.cs
index 141cccf..67c94f4 100644
--- a/Packages/src/Runtime/Internal/Utilities/ObjectPool.cs
+++ b/Packages/src/Runtime/Internal/Utilities/ObjectPool.cs
@@ -34,7 +34,7 @@ namespace Coffee.UIParticleInternal
}
// If there are no instances in the pool, create a new one.
- Logging.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
+ Logger.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
return _pool.Get();
}
@@ -47,7 +47,7 @@ namespace Coffee.UIParticleInternal
if (instance == null) return; // Ignore if already pooled or null.
_pool.Release(instance);
- Logging.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
+ Logger.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
instance = default; // Set the reference to null.
}
#else
@@ -80,7 +80,7 @@ namespace Coffee.UIParticleInternal
}
// If there are no instances in the pool, create a new one.
- Logging.Log(this, $"A new instance is created (pooled: {_pool.Count}, created: {++_count}).");
+ Logger.Log(this, $"A new instance is created (pooled: {_pool.Count}, created: {++_count}).");
return _onCreate();
}
@@ -94,7 +94,7 @@ namespace Coffee.UIParticleInternal
_onReturn(instance); // Return the instance to the pool.
_pool.Push(instance);
- Logging.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
+ Logger.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
instance = default; // Set the reference to null.
}
#endif
diff --git a/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs
index 9f47e16..037b0d7 100644
--- a/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs
+++ b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs
@@ -103,7 +103,7 @@ namespace Coffee.UIParticleInternal
Release(ref obj);
++entry.reference;
obj = entry.storedObject;
- Logging.Log(_name, $"Get(total#{count}): {entry}");
+ Logger.Log(_name, $"Get(total#{count}): {entry}");
}
Profiler.EndSample();
@@ -131,7 +131,7 @@ namespace Coffee.UIParticleInternal
newEntry.reference = 1;
_cache[hash] = newEntry;
_objectKey[newObject.GetHashCode()] = hash;
- Logging.Log(_name, $"Add(total#{count}): {newEntry}");
+ Logger.Log(_name, $"Add(total#{count}): {newEntry}");
Release(ref obj);
obj = newObject;
Profiler.EndSample();
@@ -157,12 +157,12 @@ namespace Coffee.UIParticleInternal
}
else
{
- Logging.Log(_name, $"Release(total#{_cache.Count}): {entry}");
+ Logger.Log(_name, $"Release(total#{_cache.Count}): {entry}");
}
}
else
{
- Logging.Log(_name, $"Release(total#{_cache.Count}): Already released: {obj}");
+ Logger.Log(_name, $"Release(total#{_cache.Count}): Already released: {obj}");
}
obj = null;
@@ -178,7 +178,7 @@ namespace Coffee.UIParticleInternal
_objectKey.Remove(entry.storedObject.GetHashCode());
_pool.Push(entry);
entry.reference = 0;
- Logging.Log(_name, $"Remove(total#{_cache.Count}): {entry}");
+ Logger.Log(_name, $"Remove(total#{_cache.Count}): {entry}");
entry.Release(_onRelease);
Profiler.EndSample();
}
diff --git a/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs b/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs
index 6ad33ed..758536a 100755
--- a/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs
+++ b/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs
@@ -1,4 +1,5 @@
using System;
+using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
@@ -20,7 +21,7 @@ namespace Coffee.UIParticleInternal
static UIExtraCallbacks()
{
Canvas.willRenderCanvases += OnBeforeCanvasRebuild;
- Logging.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
+ Logger.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
}
///
@@ -67,9 +68,17 @@ namespace Coffee.UIParticleInternal
if (s_IsInitializedAfterCanvasRebuild) return;
s_IsInitializedAfterCanvasRebuild = true;
+ // Explicitly set `Canvas.willRenderCanvases += CanvasUpdateRegistry.PerformUpdate`.
CanvasUpdateRegistry.IsRebuildingLayout();
+#if TMP_ENABLE
+ // Explicitly set `Canvas.willRenderCanvases += TMP_UpdateManager.DoRebuilds`.
+ typeof(TMPro.TMP_UpdateManager)
+ .GetProperty("instance", BindingFlags.NonPublic | BindingFlags.Static)
+ .GetValue(null);
+#endif
+ Canvas.willRenderCanvases -= OnAfterCanvasRebuild;
Canvas.willRenderCanvases += OnAfterCanvasRebuild;
- Logging.LogMulticast(typeof(Canvas), "willRenderCanvases",
+ Logger.LogMulticast(typeof(Canvas), "willRenderCanvases",
message: "InitializeAfterCanvasRebuild");
}