Pro_Unit

GetInerfaceType

Jun 2nd, 2020
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1.  public static T GetInerfaceType<T>(this UnityEngine.Object obj) where T : class
  2.         {
  3.             T instance = default;
  4.             if (instance == null && obj as T != null)
  5.                 instance = obj as T;
  6.  
  7.             if (instance == null && obj as GameObject != null)
  8.                 instance = (obj as GameObject).GetComponent<T>();
  9.             return instance;
  10.         }
Add Comment
Please, Sign In to add comment