private static Vector3 DoPlanarHandle(PlaneHandle planeID, Vector3 handlePos, Quaternion rotation, float handleSize, float alpha) { int num = 0; int num2 = 0; switch (planeID) { case PlaneHandle.xyPlane: Handles.color = new Color(Handles.zAxisColor.r, Handles.zAxisColor.g, Handles.zAxisColor.b, alpha); num = 0; num2 = 1; break; case PlaneHandle.xzPlane: Handles.color = new Color(Handles.yAxisColor.r, Handles.yAxisColor.g, Handles.yAxisColor.b, alpha); num = 0; num2 = 2; break; case PlaneHandle.yzPlane: Handles.color = new Color(Handles.xAxisColor.r, Handles.xAxisColor.g, Handles.xAxisColor.b, alpha); num = 1; num2 = 2; break; } int index = 3 - num2 - num; Color color = Handles.color; Matrix4x4 matrix4x = Matrix4x4.TRS(handlePos, rotation, Vector3.one); Vector3 normalized; if (Camera.current.orthographic) { normalized = matrix4x.inverse.MultiplyVector(SceneView.currentDrawingSceneView.rotation * -Vector3.forward).normalized; } else { normalized = matrix4x.inverse.MultiplyPoint(SceneView.currentDrawingSceneView.camera.transform.position).normalized; } Vector3 result = handlePos; if (Mathf.Abs(normalized[index]) < 0.05f) { Handles.color = color; result = handlePos; } else { int id = GUIUtility.GetControlID(planeID.GetHashCode(), FocusType.Passive); Vector3 offset = Vector3.one; offset[num] = (normalized[num] >= -0.01f) ? 1 : -1; offset[num2] = (normalized[num2] >= -0.01f) ? 1 : -1; offset[index] = 0f; offset = rotation * (offset * handleSize * 0.5f); Vector3 slideDir1 = Vector3.zero; Vector3 slideDir2 = Vector3.zero; Vector3 handleDir = Vector3.zero; slideDir1[num] = 1f; slideDir2[num2] = 1f; handleDir[index] = 1f; slideDir1 = rotation * slideDir1; slideDir2 = rotation * slideDir2; handleDir = rotation * handleDir; Vector3[] verts = new Vector3[4] { handlePos + offset + (slideDir1 + slideDir2) * handleSize * 0.5f, handlePos + offset + (-slideDir1 + slideDir2) * handleSize * 0.5f, handlePos + offset + (-slideDir1 - slideDir2) * handleSize * 0.5f, handlePos + offset + (slideDir1 - slideDir2) * handleSize * 0.5f }; Vector3 snapSettings = new Vector3(EditorPrefs.GetFloat("MoveSnapX"), EditorPrefs.GetFloat("MoveSnapY"), EditorPrefs.GetFloat("MoveSnapZ")); Handles.DrawSolidRectangleWithOutline(verts, new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0.1f), new Color(0f, 0f, 0f, 0f)); handlePos = Handles.Slider2D(id, handlePos, offset, handleDir, slideDir1, slideDir2, handleSize * 0.5f, Handles.RectangleHandleCap, new Vector2(snapSettings[num], snapSettings[num2])); Handles.color = color; result = handlePos; } return(result); }
private static Vector3 DoPlanarHandle(PlaneHandle planeID, Vector3 position, Quaternion rotation, float handleSize) { Vector3 normalized; int num = 0; int num2 = 0; int hint = 0; bool flag = (!Tools.s_Hidden && EditorApplication.isPlaying) && GameObjectUtility.ContainsStatic(Selection.gameObjects); if (planeID != PlaneHandle.xzPlane) { if (planeID == PlaneHandle.xyPlane) { num = 0; num2 = 1; Handles.color = !flag ? zAxisColor : staticColor; hint = s_xyAxisMoveHandleHash; } else if (planeID == PlaneHandle.yzPlane) { num = 1; num2 = 2; Handles.color = !flag ? xAxisColor : staticColor; hint = s_yzAxisMoveHandleHash; } } else { num = 0; num2 = 2; Handles.color = !flag ? yAxisColor : staticColor; hint = s_xzAxisMoveHandleHash; } int num4 = (3 - num2) - num; Color color = Handles.color; Matrix4x4 matrixx = Matrix4x4.TRS(position, rotation, Vector3.one); if (Camera.current.orthographic) { normalized = matrixx.inverse.MultiplyVector((Vector3) (SceneView.currentDrawingSceneView.cameraTargetRotation * -Vector3.forward)).normalized; } else { normalized = matrixx.inverse.MultiplyPoint(SceneView.currentDrawingSceneView.camera.transform.position).normalized; } int controlID = GUIUtility.GetControlID(hint, FocusType.Keyboard); if ((Mathf.Abs(normalized[num4]) < 0.05f) && (GUIUtility.hotControl != controlID)) { Handles.color = color; return position; } if (!currentlyDragging) { s_PlanarHandlesOctant[num] = (normalized[num] >= -0.01f) ? ((float) 1) : ((float) (-1)); s_PlanarHandlesOctant[num2] = (normalized[num2] >= -0.01f) ? ((float) 1) : ((float) (-1)); } Vector3 offset = s_PlanarHandlesOctant; offset[num4] = 0f; offset = (Vector3) (rotation * ((offset * handleSize) * 0.5f)); Vector3 zero = Vector3.zero; Vector3 vector7 = Vector3.zero; Vector3 handleDir = Vector3.zero; zero[num] = 1f; vector7[num2] = 1f; handleDir[num4] = 1f; zero = (Vector3) (rotation * zero); vector7 = (Vector3) (rotation * vector7); handleDir = (Vector3) (rotation * handleDir); verts[0] = (position + offset) + ((Vector3) (((zero + vector7) * handleSize) * 0.5f)); verts[1] = (position + offset) + ((Vector3) (((-zero + vector7) * handleSize) * 0.5f)); verts[2] = (position + offset) + ((Vector3) (((-zero - vector7) * handleSize) * 0.5f)); verts[3] = (position + offset) + ((Vector3) (((zero - vector7) * handleSize) * 0.5f)); DrawSolidRectangleWithOutline(verts, new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0.1f), new Color(0f, 0f, 0f, 0f)); if (<>f__mg$cache6 == null) {
private static Vector3 DoPlanarHandle(PlaneHandle planeID, Vector3 position, Quaternion rotation, float handleSize) { int num = 0; int num2 = 0; int hint = 0; bool flag = !Tools.s_Hidden; switch (planeID) { case PlaneHandle.xzPlane: num = 0; num2 = 2; RuntimeHandles.color = ((!flag) ? yAxisColor : staticColor); hint = s_xzAxisMoveHandleHash; break; case PlaneHandle.xyPlane: num = 0; num2 = 1; RuntimeHandles.color = ((!flag) ? zAxisColor : staticColor); hint = s_xyAxisMoveHandleHash; break; case PlaneHandle.yzPlane: num = 1; num2 = 2; RuntimeHandles.color = ((!flag) ? xAxisColor : staticColor); hint = s_yzAxisMoveHandleHash; break; } int index = 3 - num2 - num; Color color = RuntimeHandles.color; Matrix4x4 matrix4x = Matrix4x4.TRS(position, rotation, Vector3.one); Vector3 normalized; if (currentCamera.orthographic) { normalized = matrix4x.inverse.MultiplyVector(currentCamera.transform.rotation * -Vector3.forward).normalized; } else { normalized = matrix4x.inverse.MultiplyPoint(currentCamera.transform.position).normalized; } int controlID = GUIUtility.GetControlID(hint, FocusType.Keyboard); if (Mathf.Abs(normalized[index]) < 0.05f && GUIUtility.hotControl != controlID) { RuntimeHandles.color = color; return(position); } if (!currentlyDragging) { s_PlanarHandlesOctant[num] = (float)((normalized[num] >= -0.01f) ? 1 : -1); s_PlanarHandlesOctant[num2] = (float)((normalized[num2] >= -0.01f) ? 1 : -1); } Vector3 vector = s_PlanarHandlesOctant; vector[index] = 0f; vector = rotation * (vector * handleSize * 0.5f); Vector3 vector2 = Vector3.zero; Vector3 vector3 = Vector3.zero; Vector3 vector4 = Vector3.zero; vector2[num] = 1f; vector3[num2] = 1f; vector4[index] = 1f; vector2 = rotation * vector2; vector3 = rotation * vector3; vector4 = rotation * vector4; verts[0] = position + vector + (vector2 + vector3) * handleSize * 0.5f; verts[1] = position + vector + (-vector2 + vector3) * handleSize * 0.5f; verts[2] = position + vector + (-vector2 - vector3) * handleSize * 0.5f; verts[3] = position + vector + (vector2 - vector3) * handleSize * 0.5f; DrawSolidRectangleWithOutline(RuntimeHandles.verts, new Color(RuntimeHandles.color.r, RuntimeHandles.color.g, RuntimeHandles.color.b, 0.1f), new Color(0f, 0f, 0f, 0f)); position = Slider2D(controlID, position, vector, vector4, vector2, vector3, handleSize * 0.5f, RectangleCap, new Vector2(RuntimeSnapSettings.move[num], RuntimeSnapSettings.move[num2])); RuntimeHandles.color = color; return(position); }
static Vector3 DoPlanarHandle(PlaneHandle planeID, Vector3 position, Quaternion rotation, float handleSize, bool snapping, Vector3[] snapVertices, CSGHandles.InitFunction initFunction, InitFunction shutdownFunction = null) { int axis1index = 0; int axis2index = 0; int moveHandleHash = 0; var isStatic = (!Tools.hidden && EditorApplication.isPlaying && ContainsStatic(Selection.gameObjects)); switch (planeID) { case PlaneHandle.xzPlane: { axis1index = 0; axis2index = 2; Handles.color = isStatic? staticColor : Handles.yAxisColor; moveHandleHash = s_xzAxisMoveHandleHash; break; } case PlaneHandle.xyPlane: { axis1index = 0; axis2index = 1; Handles.color = isStatic? staticColor : Handles.zAxisColor; moveHandleHash = s_xyAxisMoveHandleHash; break; } case PlaneHandle.yzPlane: { axis1index = 1; axis2index = 2; Handles.color = isStatic? staticColor : Handles.xAxisColor; moveHandleHash = s_yzAxisMoveHandleHash; break; } } int axisNormalIndex = 3 - axis2index - axis1index; var prevColor = Handles.color; var handleTransform = Matrix4x4.TRS(position, rotation, Vector3.one); var sceneView = SceneView.currentDrawingSceneView; var cameraToTransformToolVector = handleTransform.inverse.MultiplyPoint(sceneView.camera.transform.position).normalized; int id = GUIUtility.GetControlID(moveHandleHash, FocusType.Keyboard); if (Mathf.Abs(cameraToTransformToolVector[axisNormalIndex]) < 0.05f && GUIUtility.hotControl != id) { Handles.color = prevColor; return(position); } if (EditorGUIUtility.hotControl == 0) { s_PlanarHandlesOctant[axis1index] = (cameraToTransformToolVector[axis1index] < -0.01f ? -1 : 1); s_PlanarHandlesOctant[axis2index] = (cameraToTransformToolVector[axis2index] < -0.01f ? -1 : 1); } var handleOffset = s_PlanarHandlesOctant; handleOffset[axisNormalIndex] = 0; handleOffset = rotation * (handleOffset * handleSize * 0.5f); var axis1 = Vector3.zero; var axis2 = Vector3.zero; var axisNormal = Vector3.zero; axis1[axis1index] = 1; axis2[axis2index] = 1; axisNormal[axisNormalIndex] = 1; axis1 = rotation * axis1; axis2 = rotation * axis2; axisNormal = rotation * axisNormal; s_Vertices[0] = position + handleOffset + (axis1 + axis2) * handleSize * 0.5f; s_Vertices[1] = position + handleOffset + (-axis1 + axis2) * handleSize * 0.5f; s_Vertices[2] = position + handleOffset + (-axis1 - axis2) * handleSize * 0.5f; s_Vertices[3] = position + handleOffset + (axis1 - axis2) * handleSize * 0.5f; var innerColor = Handles.color; var outerColor = Color.black; innerColor = new Color(innerColor.r, innerColor.g, innerColor.b, 0.1f); if (CSGHandles.disabled) { innerColor = Handles.secondaryColor; outerColor = innerColor; } Handles.DrawSolidRectangleWithOutline(s_Vertices, innerColor, outerColor); position = Slider2D(id, position, handleOffset, axisNormal, axis1, axis2, handleSize * 0.5f, RectangleHandleCap, snapping, snapVertices, initFunction, shutdownFunction); Handles.color = prevColor; return(position); }