Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MRTK3 so it can compile in Unity 2022 with no automated code changes. #11668

Merged
merged 4 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion UnityProjects/MRTKDevTemplate/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"com.unity.inputsystem": "1.6.1",
"com.unity.mobile.android-logcat": "1.3.2",
"com.unity.performance.profile-analyzer": "1.2.2",
"com.unity.project-auditor": "https://github.com/Unity-Technologies/ProjectAuditor.git",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.6.4",
Expand Down
10 changes: 1 addition & 9 deletions UnityProjects/MRTKDevTemplate/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,7 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.project-auditor": {
"version": "https://github.com/Unity-Technologies/ProjectAuditor.git",
"depth": 0,
"source": "git",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1"
},
"hash": "0fc705630268255b07f06dacd61f3205f5d5ff3c"
},

"com.unity.subsystemregistration": {
"version": "1.1.0",
"depth": 1,
Expand Down
28 changes: 21 additions & 7 deletions com.microsoft.mrtk.core/Editor/Utilities/InspectorUIUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,11 @@ public static float AxisMoveHandle(Object target, Vector3 origin, Vector3 direct

Handles.DrawDottedLine(origin, position, DottedLineScreenSpace);
Handles.ArrowHandleCap(0, position, Quaternion.LookRotation(direction), handleSize * 2, EventType.Repaint);
#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(position, handleSize, Vector3.zero, Handles.CircleHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.zero, Handles.CircleHandleCap);
#endif

if (recordUndo)
{
Expand Down Expand Up @@ -788,7 +792,11 @@ public static Vector3 CircleMoveHandle(Object target, Vector3 position, float xS
handleSize = Mathf.Lerp(handleSize, HandleUtility.GetHandleSize(position) * handleSize, 0.75f);
}

#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(position, handleSize, Vector3.zero, Handles.CircleHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.zero, Handles.CircleHandleCap);
#endif

if (recordUndo && position != newPosition)
{
Expand Down Expand Up @@ -824,7 +832,11 @@ public static Vector3 SquareMoveHandle(Object target, Vector3 position, float xS
}

// Multiply square handle to match other types
#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(position, handleSize * 0.8f, Vector3.zero, Handles.RectangleHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize * 0.8f, Vector3.zero, Handles.RectangleHandleCap);
#endif

if (recordUndo && position != newPosition)
{
Expand Down Expand Up @@ -860,7 +872,11 @@ public static Vector3 SphereMoveHandle(Object target, Vector3 position, float xS
}

// Multiply sphere handle size to match other types
#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(position, handleSize * 2, Vector3.zero, Handles.SphereHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(position, Quaternion.identity, handleSize * 2, Vector3.zero, Handles.SphereHandleCap);
#endif

if (recordUndo && position != newPosition)
{
Expand Down Expand Up @@ -920,13 +936,11 @@ public static Vector3 VectorHandle(Object target, Vector3 origin, Vector3 vector
// Draw a line from origin to origin + direction
Handles.DrawLine(origin, handlePosition);

Quaternion rotation = Quaternion.identity;
if (vector != Vector3.zero)
{
rotation = Quaternion.LookRotation(vector);
}

Vector3 newPosition = Handles.FreeMoveHandle(handlePosition, rotation, handleSize, Vector3.zero, Handles.DotHandleCap);
#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(handlePosition, handleSize, Vector3.zero, Handles.DotHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(handlePosition, Quaternion.identity, handleSize, Vector3.zero, Handles.DotHandleCap);
#endif

if (recordUndo && handlePosition != newPosition)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ private float DrawPlaneAndHandle(Vector3[] vertices, Vector2 halfExtents, float
Handles.ArrowHandleCap(0, vertices[1], Quaternion.LookRotation(planeNormal), handleSize * 2, EventType.Repaint);
Handles.ArrowHandleCap(0, vertices[1], Quaternion.LookRotation(-planeNormal), handleSize * 2, EventType.Repaint);

#if UNITY_2022_1_OR_NEWER
Vector3 newPosition = Handles.FreeMoveHandle(vertices[1], handleSize, Vector3.zero, Handles.SphereHandleCap);
#else
Vector3 newPosition = Handles.FreeMoveHandle(vertices[1], Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap);
#endif

if (!newPosition.Equals(vertices[1]))
{
distance = button.GetDistanceAlongPushDirection(newPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,32 @@ private void OnSceneGUI()
}

EditorGUI.BeginChangeCheck();


#if UNITY_2022_1_OR_NEWER
Vector3 newStartPosition = Handles.FreeMoveHandle(startPos,
handleSize,
Vector3.zero,
Handles.SphereHandleCap);
#else
Vector3 newStartPosition = Handles.FreeMoveHandle(startPos,
Quaternion.identity,
handleSize,
Vector3.zero,
Handles.SphereHandleCap);
#endif

#if UNITY_2022_1_OR_NEWER
Vector3 newEndPosition = Handles.FreeMoveHandle(endPos,
handleSize,
Vector3.zero,
Handles.SphereHandleCap);
#else
Vector3 newEndPosition = Handles.FreeMoveHandle(endPos,
Quaternion.identity,
handleSize,
Vector3.zero,
Handles.SphereHandleCap);
#endif

if (EditorGUI.EndChangeCheck())
{
Expand Down