internal static Quaternion DoRotationHandle(RotationHandleIds ids, Quaternion rotation, Vector3 position, RotationHandleParam param) { var evt = Event.current; var camForward = Handles.inverseMatrix.MultiplyVector(Camera.current != null ? Camera.current.transform.forward : Vector3.forward); var size = HandleUtility.GetHandleSize(position); var temp = color; var isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects)); var isHot = ids.Has(GUIUtility.hotControl); // Draw freerotation first to give it the lowest priority if (!isStatic && param.ShouldShow(RotationHandleParam.Handle.XYZ) && (isHot && ids.xyz == GUIUtility.hotControl || !isHot)) { color = centerColor; rotation = UnityEditorInternal.FreeRotate.Do(ids.xyz, rotation, position, size * param.xyzSize, param.displayXYZCircle); } var radiusOfAxesHandles = -1f; for (var i = 0; i < 3; ++i) { if (!param.ShouldShow(i)) { continue; } var axisColor = GetColorByAxis(i); color = isStatic ? Color.Lerp(axisColor, staticColor, staticBlend) : axisColor; color = ToActiveColorSpace(color); var axisDir = GetAxisVector(i); var radius = size * param.axisSize[i]; radiusOfAxesHandles = Mathf.Max(radius, radiusOfAxesHandles); rotation = UnityEditorInternal.Disc.Do(ids[i], rotation, position, rotation * axisDir, radius, true, SnapSettings.rotation, param.enableRayDrag, true, k_RotationPieColor); } if (radiusOfAxesHandles > 0 && evt.type == EventType.Repaint) { Handles.color = new Color(0, 0, 0, 0.2f); Handles.DrawWireDisc(position, camForward, radiusOfAxesHandles); } if (isHot && evt.type == EventType.Repaint) { color = ToActiveColorSpace(s_DisabledHandleColor); Handles.DrawWireDisc(position, camForward, size * param.axisSize[0]); } if (!isStatic && param.ShouldShow(RotationHandleParam.Handle.CameraAxis) && (isHot && ids.cameraAxis == GUIUtility.hotControl || !isHot)) { color = ToActiveColorSpace(centerColor); rotation = UnityEditorInternal.Disc.Do(ids.cameraAxis, rotation, position, camForward, size * param.cameraAxisSize, false, 0, param.enableRayDrag, true, k_RotationPieColor); } color = temp; return(rotation); }
public TransformHandleIds(PositionHandleIds position, RotationHandleIds rotation, ScaleHandleIds scale) { this.position = position; this.rotation = rotation; this.scale = scale; }