A game about forced loneliness, made by TACStudios
1using UnityEngine;
2using UnityObject = UnityEngine.Object;
3
4namespace Unity.VisualScripting
5{
6 public static class UnityObjectOwnershipUtility
7 {
8 public static void CopyOwner(object source, object destination)
9 {
10 var destinationOwned = destination as IUnityObjectOwnable;
11
12 if (destinationOwned != null)
13 {
14 destinationOwned.owner = GetOwner(source);
15 }
16 }
17
18 public static void RemoveOwner(object o)
19 {
20 var sourceOwned = o as IUnityObjectOwnable;
21
22 if (sourceOwned != null)
23 {
24 sourceOwned.owner = null;
25 }
26 }
27
28 public static UnityObject GetOwner(object o)
29 {
30 return (o as Component)?.gameObject ?? (o as IUnityObjectOwnable)?.owner;
31 }
32 }
33}