Skip to content

Commit dd7337c

Browse files
authored
perf(Extensions): Add shim for transform.GetPositionAndRotation (#3755)
Doesn't exist in unity versions 2021.2 or earlier
1 parent 158c597 commit dd7337c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Assets/Mirror/Core/Tools/Extensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Runtime.CompilerServices;
5+
using UnityEngine;
56

67
namespace Mirror
78
{
@@ -98,5 +99,14 @@ public static void Clear<T>(this ConcurrentQueue<T> source)
9899
}
99100
}
100101
#endif
102+
103+
#if !UNITY_2021_3_OR_NEWER
104+
// Unity 2021.2 and earlier don't have transform.GetPositionAndRotation which we use for performance in some places
105+
public static void GetPositionAndRotation(this Transform transform, out Vector3 position, out Quaternion rotation)
106+
{
107+
position = transform.position;
108+
rotation = transform.rotation;
109+
}
110+
#endif
101111
}
102112
}

0 commit comments

Comments
 (0)