Pro_Unit

UnityObjectExtensions

Apr 6th, 2022 (edited)
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace StrongExtensions
  4. {
  5.     public static class UnityObjectExtensions
  6.     {
  7.         public static TObject Instantiate<TObject>(this TObject value)
  8.             where TObject : Object
  9.             => Object.Instantiate(value);
  10.  
  11.         public static TObject Instantiate<TObject>(this TObject value, Transform parent)
  12.             where TObject : Object
  13.             => Object.Instantiate(value, parent);
  14.        
  15.  
  16.         public static TObject Instantiate<TObject>(this TObject value, Transform parent, bool worldPositionStays)
  17.             where TObject : Object
  18.             => Object.Instantiate(value, parent, worldPositionStays);
  19.  
  20.         public static TObject Instantiate<TObject>(this TObject value, Vector3 position, Quaternion rotation)
  21.             where TObject : Object
  22.             => Object.Instantiate(value, position, rotation);
  23.  
  24.         public static TObject Instantiate<TObject>(this TObject value, Vector3 position, Quaternion rotation, Transform parent)
  25.             where TObject : Object
  26.             => Object.Instantiate(value, position, rotation, parent);
  27.  
  28.         public static void Destroy(this Object value)
  29.             => Object.Destroy(value);
  30.  
  31.         public static void DestroyImmediate(this Object value)
  32.             => Object.DestroyImmediate(value);
  33.  
  34.         public static void DontDestroyOnLoad(this Object value)
  35.             => Object.DontDestroyOnLoad(value);
  36.     }
  37. }
Add Comment
Please, Sign In to add comment