diff --git a/Runtime/Internal/Extensions/ComponentExtensions.cs b/Runtime/Internal/Extensions/ComponentExtensions.cs
index f133e01..255ef6b 100644
--- a/Runtime/Internal/Extensions/ComponentExtensions.cs
+++ b/Runtime/Internal/Extensions/ComponentExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Profiling;
@@ -11,6 +12,48 @@ namespace Coffee.UIParticleInternal
///
internal static class ComponentExtensions
{
+ ///
+ /// Get components in children of a specific type in the hierarchy of a GameObject.
+ ///
+ public static T[] GetComponentsInChildren(this Component self, int depth)
+ where T : Component
+ {
+ var results = ListPool.Rent();
+ self.GetComponentsInChildren_Internal(results, depth);
+ var array = results.ToArray();
+ ListPool.Return(ref results);
+ return array;
+ }
+
+ ///
+ /// Get components in children of a specific type in the hierarchy of a GameObject.
+ ///
+ public static void GetComponentsInChildren(this Component self, List results, int depth)
+ where T : Component
+ {
+ results.Clear();
+ self.GetComponentsInChildren_Internal(results, depth);
+ }
+
+ private static void GetComponentsInChildren_Internal(this Component self, List results, int depth)
+ where T : Component
+ {
+ if (!self || results == null || depth < 0) return;
+
+ var tr = self.transform;
+ if (tr.TryGetComponent(out var t))
+ {
+ results.Add(t);
+ }
+
+ if (depth - 1 < 0) return;
+ var childCount = tr.childCount;
+ for (var i = 0; i < childCount; i++)
+ {
+ tr.GetChild(i).GetComponentsInChildren(results, depth - 1);
+ }
+ }
+
///
/// Get or add a component of a specific type to a GameObject.
///
diff --git a/Runtime/Internal/Utilities/Logging.cs b/Runtime/Internal/Utilities/Logging.cs
index f03570e..d9a2f5e 100644
--- a/Runtime/Internal/Utilities/Logging.cs
+++ b/Runtime/Internal/Utilities/Logging.cs
@@ -1,11 +1,13 @@
using System;
using System.Text;
using UnityEngine;
-using Conditional = System.Diagnostics.ConditionalAttribute;
using Object = UnityEngine.Object;
#if ENABLE_COFFEE_LOGGER
using System.Reflection;
using System.Collections.Generic;
+
+#else
+using Conditional = System.Diagnostics.ConditionalAttribute;
#endif
namespace Coffee.UIParticleInternal
diff --git a/Runtime/Internal/Utilities/MaterialRepository.cs b/Runtime/Internal/Utilities/MaterialRepository.cs
index e9340a1..89ad52a 100644
--- a/Runtime/Internal/Utilities/MaterialRepository.cs
+++ b/Runtime/Internal/Utilities/MaterialRepository.cs
@@ -42,6 +42,34 @@ namespace Coffee.UIParticleInternal
Profiler.EndSample();
}
+ ///
+ /// Adds or retrieves a cached material based on the hash.
+ ///
+ public static void Get(Hash128 hash, ref Material material, string shaderName)
+ {
+ Profiler.BeginSample("(COF)[MaterialRepository] Get");
+ s_Repository.Get(hash, ref material, x => new Material(Shader.Find(x))
+ {
+ hideFlags = HideFlags.DontSave | HideFlags.NotEditable
+ }, shaderName);
+ Profiler.EndSample();
+ }
+
+
+ ///
+ /// Adds or retrieves a cached material based on the hash.
+ ///
+ public static void Get(Hash128 hash, ref Material material, string shaderName, string[] keywords)
+ {
+ Profiler.BeginSample("(COF)[MaterialRepository] Get");
+ s_Repository.Get(hash, ref material, x => new Material(Shader.Find(x.shaderName))
+ {
+ hideFlags = HideFlags.DontSave | HideFlags.NotEditable,
+ shaderKeywords = x.keywords
+ }, (shaderName, keywords));
+ Profiler.EndSample();
+ }
+
///
/// Adds or retrieves a cached material based on the hash.
///