From e4e23afd9c75a1ec910552ed87f8bf2d296bf54d Mon Sep 17 00:00:00 2001 From: Robin Rolf Date: Mon, 29 Jan 2024 18:49:31 +0100 Subject: [PATCH] perf(Extensions): Add shim for transform.GetPositionAndRotation (#3755) Doesn't exist in unity versions 2021.2 or earlier --- Assets/Mirror/Core/Tools/Extensions.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Assets/Mirror/Core/Tools/Extensions.cs b/Assets/Mirror/Core/Tools/Extensions.cs index 0039f571d..196be4b19 100644 --- a/Assets/Mirror/Core/Tools/Extensions.cs +++ b/Assets/Mirror/Core/Tools/Extensions.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Runtime.CompilerServices; +using UnityEngine; namespace Mirror { @@ -98,5 +99,14 @@ public static void Clear(this ConcurrentQueue 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 } }