public void ClearTransformTemporarily()
 {
     if (memory == null)
     {
         memory = TransformMemory.SaveAndReset(transform);
     }
 }
        public static TransformMemory SaveAndReset(Transform transform)
        {
            var memory = new TransformMemory(transform);

            transform.SetParent(null, worldPositionStays: false);
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;
            transform.localScale    = Vector3.one;

            return(memory);
        }
 public void RestorePosition()
 {
     memory.Apply(transform);
     memory = null;
 }