|
3 | 3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License |
4 | 4 |
|
5 | 5 | using System; |
6 | | -using UnityEditor.Snap; |
7 | 6 | using UnityEngine; |
8 | 7 |
|
9 | 8 | namespace UnityEditor |
@@ -222,6 +221,8 @@ internal static Vector3 DoPositionHandle(PositionHandleIds ids, Vector3 position |
222 | 221 | static int[] s_DoPositionHandle_Internal_NextIndex = { 1, 2, 0 }; |
223 | 222 | static int[] s_DoPositionHandle_Internal_PrevIndex = { 2, 0, 1 }; |
224 | 223 | static int[] s_DoPositionHandle_Internal_PrevPlaneIndex = { 5, 3, 4 }; |
| 224 | + static int[] s_DoPositionHandle_Internal_AxisDrawOrder = { 0, 1, 2 }; |
| 225 | + |
225 | 226 | static Vector3 DoPositionHandle_Internal(PositionHandleIds ids, Vector3 position, Quaternion rotation, PositionHandleParam param) |
226 | 227 | { |
227 | 228 | Color temp = color; |
@@ -271,8 +272,11 @@ static Vector3 DoPositionHandle_Internal(PositionHandleIds ids, Vector3 position |
271 | 272 | } |
272 | 273 |
|
273 | 274 | // Draw axis sliders last to have priority over the planes |
274 | | - for (var i = 0; i < 3; ++i) |
| 275 | + CalcDrawOrder(viewVectorDrawSpace, s_DoPositionHandle_Internal_AxisDrawOrder); |
| 276 | + for (var ii = 0; ii < 3; ++ii) |
275 | 277 | { |
| 278 | + int i = s_DoPositionHandle_Internal_AxisDrawOrder[ii]; |
| 279 | + |
276 | 280 | if (!param.ShouldShow(i)) |
277 | 281 | continue; |
278 | 282 |
|
@@ -300,7 +304,7 @@ static Vector3 DoPositionHandle_Internal(PositionHandleIds ids, Vector3 position |
300 | 304 |
|
301 | 305 | if (cameraLerp <= kCameraViewThreshold) |
302 | 306 | { |
303 | | - color = Color.Lerp(color, Color.clear, cameraLerp); |
| 307 | + color = GetFadedAxisColor(color, cameraLerp, ids[i]); |
304 | 308 | var axisVector = GetAxisVector(i); |
305 | 309 | var dir = rotation * axisVector; |
306 | 310 | var offset = dir * axisOffset[i] * size; |
@@ -362,15 +366,15 @@ static Vector3 DoPlanarHandle( |
362 | 366 |
|
363 | 367 | bool isDisabled = !GUI.enabled; |
364 | 368 | color = isDisabled ? staticColor : GetColorByAxis(axisNormalIndex); |
365 | | - color = Color.Lerp(color, Color.clear, cameraLerp); |
| 369 | + color = GetFadedAxisColor(color, cameraLerp, id); |
366 | 370 |
|
367 | | - var updateOpacityFillColor = false; |
| 371 | + float faceOpacity = 0.8f; |
368 | 372 | if (GUIUtility.hotControl == id) |
369 | 373 | color = selectedColor; |
370 | | - else if (HandleUtility.nearestControl == id && !Event.current.alt) |
371 | | - color = preselectionColor; |
| 374 | + else if (IsHovering(id, Event.current)) |
| 375 | + faceOpacity = 0.4f; |
372 | 376 | else |
373 | | - updateOpacityFillColor = true; |
| 377 | + faceOpacity = 0.1f; |
374 | 378 |
|
375 | 379 | color = ToActiveColorSpace(color); |
376 | 380 |
|
@@ -427,8 +431,7 @@ static Vector3 DoPlanarHandle( |
427 | 431 | verts[1] = position + positionOffset + handleOffset + (-axis1 + axis2) * handleSize * 0.5f; |
428 | 432 | verts[2] = position + positionOffset + handleOffset + (-axis1 - axis2) * handleSize * 0.5f; |
429 | 433 | verts[3] = position + positionOffset + handleOffset + (axis1 - axis2) * handleSize * 0.5f; |
430 | | - Color faceColor = updateOpacityFillColor ? new Color(color.r, color.g, color.b, 0.1f) : color; |
431 | | - faceColor = ToActiveColorSpace(faceColor); |
| 434 | + Color faceColor = new Color(color.r, color.g, color.b, color.a * faceOpacity); |
432 | 435 | Handles.DrawSolidRectangleWithOutline(verts, faceColor, Color.clear); |
433 | 436 |
|
434 | 437 | // And then render the handle itself (this is the colored outline) |
|
0 commit comments