Skip to content

Commit

Permalink
perf(Extensions): Add shim for transform.GetPositionAndRotation (#3755)
Browse files Browse the repository at this point in the history
Doesn't exist in unity versions 2021.2 or earlier
  • Loading branch information
imerr authored Jan 29, 2024
1 parent 158c597 commit dd7337c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Assets/Mirror/Core/Tools/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace Mirror
{
Expand Down Expand Up @@ -98,5 +99,14 @@ public static void Clear<T>(this ConcurrentQueue<T> source)
}
}
#endif

#if !UNITY_2021_3_OR_NEWER
// Unity 2021.2 and earlier don't have transform.GetPositionAndRotation which we use for performance in some places
public static void GetPositionAndRotation(this Transform transform, out Vector3 position, out Quaternion rotation)
{
position = transform.position;
rotation = transform.rotation;
}
#endif
}
}

0 comments on commit dd7337c

Please sign in to comment.