mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-21 10:22:37 +08:00
@@ -20,7 +20,9 @@ namespace Coffee.UIEffectInternal
|
|||||||
{
|
{
|
||||||
public static T[] FindObjectsOfType<T>() where T : Object
|
public static T[] FindObjectsOfType<T>() where T : Object
|
||||||
{
|
{
|
||||||
#if UNITY_2023_1_OR_NEWER
|
#if UNITY_6000_4_OR_NEWER
|
||||||
|
return Object.FindObjectsByType<T>(FindObjectsInactive.Include);
|
||||||
|
#elif UNITY_2023_1_OR_NEWER
|
||||||
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||||
#else
|
#else
|
||||||
return Object.FindObjectsOfType<T>();
|
return Object.FindObjectsOfType<T>();
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace Coffee.UIEffectInternal
|
|||||||
newEntry.hash = hash;
|
newEntry.hash = hash;
|
||||||
newEntry.reference = 1;
|
newEntry.reference = 1;
|
||||||
_cache[hash] = newEntry;
|
_cache[hash] = newEntry;
|
||||||
_objectKey[newObject.GetInstanceID()] = hash;
|
_objectKey[newObject.GetHashCode()] = hash;
|
||||||
Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
|
Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
|
||||||
Release(ref obj);
|
Release(ref obj);
|
||||||
obj = newObject;
|
obj = newObject;
|
||||||
@@ -146,7 +146,7 @@ namespace Coffee.UIEffectInternal
|
|||||||
|
|
||||||
// Find and release the entry.
|
// Find and release the entry.
|
||||||
Profiler.BeginSample("(COF)[ObjectRepository] Release");
|
Profiler.BeginSample("(COF)[ObjectRepository] Release");
|
||||||
var id = obj.GetInstanceID();
|
var id = obj.GetHashCode();
|
||||||
if (_objectKey.TryGetValue(id, out var hash)
|
if (_objectKey.TryGetValue(id, out var hash)
|
||||||
&& _cache.TryGetValue(hash, out var entry))
|
&& _cache.TryGetValue(hash, out var entry))
|
||||||
{
|
{
|
||||||
@@ -175,7 +175,7 @@ namespace Coffee.UIEffectInternal
|
|||||||
|
|
||||||
Profiler.BeginSample("(COF)[ObjectRepository] Remove");
|
Profiler.BeginSample("(COF)[ObjectRepository] Remove");
|
||||||
_cache.Remove(entry.hash);
|
_cache.Remove(entry.hash);
|
||||||
_objectKey.Remove(entry.storedObject.GetInstanceID());
|
_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}");
|
Logging.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}");
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace Coffee.UIEffectInternal
|
|||||||
if (!shader) return null;
|
if (!shader) return null;
|
||||||
|
|
||||||
// Already cached.
|
// Already cached.
|
||||||
var id = shader.GetInstanceID();
|
var id = shader.GetHashCode();
|
||||||
if (_cachedOptionalShaders.TryGetValue(id, out var optionalShaderName))
|
if (_cachedOptionalShaders.TryGetValue(id, out var optionalShaderName))
|
||||||
{
|
{
|
||||||
return Shader.Find(optionalShaderName);
|
return Shader.Find(optionalShaderName);
|
||||||
@@ -270,7 +270,7 @@ namespace Coffee.UIEffectInternal
|
|||||||
_sb.Length--; // Remove last space.
|
_sb.Length--; // Remove last space.
|
||||||
}
|
}
|
||||||
|
|
||||||
var hash = new Hash128((uint)shader.GetInstanceID(), (uint)GetContentsHash(_sb), 0, 0);
|
var hash = new Hash128((uint)shader.GetHashCode(), (uint)GetContentsHash(_sb), 0, 0);
|
||||||
if (_cachedVariants.TryGetValue(hash, out var result))
|
if (_cachedVariants.TryGetValue(hash, out var result))
|
||||||
{
|
{
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Coffee.UIEffects
|
|||||||
|
|
||||||
public Material effectMaterial => _material;
|
public Material effectMaterial => _material;
|
||||||
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
|
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
|
||||||
public virtual uint effectId => (uint)GetInstanceID();
|
public virtual uint effectId => (uint)GetHashCode();
|
||||||
public virtual float actualSamplingScale => 1;
|
public virtual float actualSamplingScale => 1;
|
||||||
public virtual bool canModifyShape => true;
|
public virtual bool canModifyShape => true;
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ namespace Coffee.UIEffects
|
|||||||
|
|
||||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
||||||
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
|
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
|
||||||
var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0);
|
var rootId = (uint)(transitionRoot ? transitionRoot.GetHashCode() : 0);
|
||||||
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
|
var hash = new Hash128((uint)baseMaterial.GetHashCode(), effectId, samplingScaleId, rootId);
|
||||||
if (!MaterialRepository.Valid(hash, _material))
|
if (!MaterialRepository.Valid(hash, _material))
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
|
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ namespace Coffee.UIEffects
|
|||||||
public override uint effectId => target
|
public override uint effectId => target
|
||||||
? target.effectId
|
? target.effectId
|
||||||
: preset
|
: preset
|
||||||
? (uint)preset.GetInstanceID()
|
? (uint)preset.GetHashCode()
|
||||||
: (uint)GetInstanceID();
|
: (uint)GetHashCode();
|
||||||
|
|
||||||
|
|
||||||
public override UIEffectContext context
|
public override UIEffectContext context
|
||||||
|
|||||||
Reference in New Issue
Block a user