public static T GetScriptableObjectInterface <T>(this UnityEngine.ScriptableObject o) { var targetType = typeof(T); var objectType = o.GetType(); foreach (var objectInterface in objectType.GetInterfaces()) { if (objectInterface == targetType) { return(o.To <T>()); } } return(default(T)); }
public static List <T> GetScriptableObjectInterfaces <T>(this UnityEngine.ScriptableObject o) { var result = new List <T>(); var targetType = typeof(T); var objectType = o.GetType(); foreach (var objectInterface in objectType.GetInterfaces()) { if (objectInterface == targetType) { result.Add(o.To <T>()); } } return(result); }