diff options
Diffstat (limited to 'Thronefall_1_57/Decompile/Thronefall/FreezePositionOnEnable.cs')
| -rw-r--r-- | Thronefall_1_57/Decompile/Thronefall/FreezePositionOnEnable.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Thronefall_1_57/Decompile/Thronefall/FreezePositionOnEnable.cs b/Thronefall_1_57/Decompile/Thronefall/FreezePositionOnEnable.cs new file mode 100644 index 0000000..60685aa --- /dev/null +++ b/Thronefall_1_57/Decompile/Thronefall/FreezePositionOnEnable.cs @@ -0,0 +1,25 @@ +using UnityEngine; + +public class FreezePositionOnEnable : MonoBehaviour +{ + private Transform oldParent; + + private void OnEnable() + { + if (oldParent == null) + { + oldParent = base.transform.parent; + } + base.transform.SetParent(null); + base.transform.position = oldParent.position; + base.transform.rotation = oldParent.rotation; + } + + private void Update() + { + if (!oldParent.gameObject.activeInHierarchy) + { + base.transform.SetParent(oldParent); + } + } +} |
