You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In MRTK3 implement a generic component object cache. This would be a generic class with a type parameter T. The generic class should be capable is searching for type T, and cache the first found instance of T. T must derive from the Unity Component base class.
Class definition
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit
{
static class ComponentCache<T> where T : Componet
{
private static T cache = null;
public static T FindFirstInstance()
{
_ = TryFindFirstInstance(out T result);
return result;
}
public static bool TryFindFirstInstance(out T result)
{
if (cache == null)
{
cache = Object.FindFirstObjectByType<T>();
}
result = cache;
return result != null;
}
}
}
Original issue opened by:
marlenaklein-msft
Overview
In MRTK3 implement a generic component object cache. This would be a generic class with a type parameter T. The generic class should be capable is searching for type T, and cache the first found instance of T. T must derive from the Unity Component base class.
Class definition
ISSUE MIGRATION
Issue migrated from: microsoft/MixedRealityToolkit-Unity#11682
The text was updated successfully, but these errors were encountered: