예제 #1
0
    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));
    }
예제 #2
0
    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);
    }