update internal code

This commit is contained in:
mob-sakai
2026-06-08 13:27:27 +09:00
parent b740dd662d
commit 48b38ec34f
10 changed files with 31 additions and 49 deletions

View File

@@ -37,37 +37,17 @@ namespace Coffee.UIExtensions
switch (type) switch (type)
{ {
case ShaderPropertyType.Color: case ShaderPropertyType.Color:
var color = mpb.GetColor(id); material.SetColor(id, mpb.GetColor(id));
if (color != default)
{
material.SetColor(id, color);
}
break; break;
case ShaderPropertyType.Vector: case ShaderPropertyType.Vector:
var vector = mpb.GetVector(id); material.SetVector(id, mpb.GetVector(id));
if (vector != default)
{
material.SetVector(id, vector);
}
break; break;
case ShaderPropertyType.Float: case ShaderPropertyType.Float:
case ShaderPropertyType.Range: case ShaderPropertyType.Range:
var value = mpb.GetFloat(id); material.SetFloat(id, mpb.GetFloat(id));
if (!Mathf.Approximately(value, 0))
{
material.SetFloat(id, value);
}
break; break;
case ShaderPropertyType.Texture: case ShaderPropertyType.Texture:
var tex = mpb.GetTexture(id); material.SetTexture(id, mpb.GetTexture(id));
if (tex != default(Texture))
{
material.SetTexture(id, tex);
}
break; break;
} }
} }

View File

@@ -184,7 +184,7 @@ namespace Coffee.UIParticleInternal
/// <summary> /// <summary>
/// Verify whether it can be converted to the specified component. /// Verify whether it can be converted to the specified component.
/// </summary> /// </summary>
internal static bool CanConvertTo<T>(this Object context) where T : MonoBehaviour internal static bool CanConvertTo<T>(this Object context) where T : MonoBehaviour
{ {
return context != null && context.GetType() != typeof(T); return context != null && context.GetType() != typeof(T);
} }

View File

@@ -158,6 +158,8 @@ namespace Coffee.UIParticleInternal
private void OnPlayModeStateChanged(PlayModeStateChange state) private void OnPlayModeStateChanged(PlayModeStateChange state)
{ {
if (!this) return;
switch (state) switch (state)
{ {
case PlayModeStateChange.ExitingEditMode: case PlayModeStateChange.ExitingEditMode:

View File

@@ -11,7 +11,7 @@ using Conditional = System.Diagnostics.ConditionalAttribute;
namespace Coffee.UIParticleInternal namespace Coffee.UIParticleInternal
{ {
internal static class Logging internal static class Logger
{ {
#if !ENABLE_COFFEE_LOGGER #if !ENABLE_COFFEE_LOGGER
private const string k_DisableSymbol = "DISABLE_COFFEE_LOGGER"; private const string k_DisableSymbol = "DISABLE_COFFEE_LOGGER";

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4f9f22bb079324476b1473030ad9fec3

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8255313895da84e7cbdc876be3795334
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -20,7 +20,7 @@ namespace Coffee.UIParticleInternal
{ {
public static T[] FindObjectsOfType<T>() where T : Object public static T[] FindObjectsOfType<T>() where T : Object
{ {
#if UNITY_6000_5_OR_NEWER #if UNITY_6000_4_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include); return Object.FindObjectsByType<T>(FindObjectsInactive.Include);
#elif UNITY_2023_1_OR_NEWER #elif UNITY_2023_1_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None); return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);

View File

@@ -34,7 +34,7 @@ namespace Coffee.UIParticleInternal
} }
// If there are no instances in the pool, create a new one. // 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(); return _pool.Get();
} }
@@ -47,7 +47,7 @@ namespace Coffee.UIParticleInternal
if (instance == null) return; // Ignore if already pooled or null. if (instance == null) return; // Ignore if already pooled or null.
_pool.Release(instance); _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. instance = default; // Set the reference to null.
} }
#else #else
@@ -80,7 +80,7 @@ namespace Coffee.UIParticleInternal
} }
// If there are no instances in the pool, create a new one. // 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(); return _onCreate();
} }
@@ -94,7 +94,7 @@ namespace Coffee.UIParticleInternal
_onReturn(instance); // Return the instance to the pool. _onReturn(instance); // Return the instance to the pool.
_pool.Push(instance); _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. instance = default; // Set the reference to null.
} }
#endif #endif

View File

@@ -103,7 +103,7 @@ namespace Coffee.UIParticleInternal
Release(ref obj); Release(ref obj);
++entry.reference; ++entry.reference;
obj = entry.storedObject; obj = entry.storedObject;
Logging.Log(_name, $"Get(total#{count}): {entry}"); Logger.Log(_name, $"Get(total#{count}): {entry}");
} }
Profiler.EndSample(); Profiler.EndSample();
@@ -131,7 +131,7 @@ namespace Coffee.UIParticleInternal
newEntry.reference = 1; newEntry.reference = 1;
_cache[hash] = newEntry; _cache[hash] = newEntry;
_objectKey[newObject.GetHashCode()] = hash; _objectKey[newObject.GetHashCode()] = hash;
Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}"); Logger.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
Release(ref obj); Release(ref obj);
obj = newObject; obj = newObject;
Profiler.EndSample(); Profiler.EndSample();
@@ -157,12 +157,12 @@ namespace Coffee.UIParticleInternal
} }
else else
{ {
Logging.Log(_name, $"Release(total#{_cache.Count}): {entry}"); Logger.Log(_name, $"Release(total#{_cache.Count}): {entry}");
} }
} }
else else
{ {
Logging.Log(_name, $"Release(total#{_cache.Count}): <color=red>Already released: {obj}</color>"); Logger.Log(_name, $"Release(total#{_cache.Count}): <color=red>Already released: {obj}</color>");
} }
obj = null; obj = null;
@@ -178,7 +178,7 @@ namespace Coffee.UIParticleInternal
_objectKey.Remove(entry.storedObject.GetHashCode()); _objectKey.Remove(entry.storedObject.GetHashCode());
_pool.Push(entry); _pool.Push(entry);
entry.reference = 0; entry.reference = 0;
Logging.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}"); Logger.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}");
entry.Release(_onRelease); entry.Release(_onRelease);
Profiler.EndSample(); Profiler.EndSample();
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Reflection;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -20,7 +21,7 @@ namespace Coffee.UIParticleInternal
static UIExtraCallbacks() static UIExtraCallbacks()
{ {
Canvas.willRenderCanvases += OnBeforeCanvasRebuild; Canvas.willRenderCanvases += OnBeforeCanvasRebuild;
Logging.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor"); Logger.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
} }
/// <summary> /// <summary>
@@ -67,9 +68,17 @@ namespace Coffee.UIParticleInternal
if (s_IsInitializedAfterCanvasRebuild) return; if (s_IsInitializedAfterCanvasRebuild) return;
s_IsInitializedAfterCanvasRebuild = true; s_IsInitializedAfterCanvasRebuild = true;
// Explicitly set `Canvas.willRenderCanvases += CanvasUpdateRegistry.PerformUpdate`.
CanvasUpdateRegistry.IsRebuildingLayout(); 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; Canvas.willRenderCanvases += OnAfterCanvasRebuild;
Logging.LogMulticast(typeof(Canvas), "willRenderCanvases", Logger.LogMulticast(typeof(Canvas), "willRenderCanvases",
message: "InitializeAfterCanvasRebuild"); message: "InitializeAfterCanvasRebuild");
} }