using System; using UnityEngine; public class GizmoRender : MonoBehaviour { public static bool control_lock { get { return GizmoRender.local_control_lock_ || GizmoRender.global_control_lock; } } public void Awake() { if (!this.lineMaterial) { Shader shader = Shader.Find("Hidden/Internal-Colored"); this.lineMaterial = new Material(shader); this.lineMaterial.hideFlags = HideFlags.HideAndDontSave; this.lineMaterial.SetInt("_ZTest", 0); this.lineMaterial.SetInt("_SrcBlend", 5); this.lineMaterial.SetInt("_DstBlend", 10); this.lineMaterial.SetInt("_Cull", 0); this.lineMaterial.SetInt("_ZWrite", 0); } this.untransRight = new Vector3(1f, 0f, 0f); this.untransUp = new Vector3(0f, 1f, 0f); this.untransForward = new Vector3(0f, 0f, 1f); this.Dir = Vector3.zero; this.colorRed = new Color(1f, 0f, 0f, 1f); this.colorGreen = new Color(0f, 1f, 0f, 1f); this.colorBlue = new Color(0f, 0f, 1f, 1f); this.colorFan = new Color(1f, 1f, 0f, 0.5f); this.colorWhite = new Color(1f, 1f, 1f, 0.3f); this.colorWire = new Color(1f, 1f, 1f, 0.05f); this.colorLine = new Color(1f, 1f, 0f, 0.8f); this.selX = this.colorRed; this.selY = this.colorGreen; this.selZ = this.colorBlue; this.panY = this.colorGreen; this.panX = this.colorRed; this.panZ = this.colorBlue; this.circleX = this.colorRed; this.circleY = this.colorGreen; this.circleZ = this.colorBlue; this.beSelectedType = GizmoRender.MOVETYPE.NONE; this.hitMouseDown = (this.hitMouseMove = Vector3.zero); this.moveLockVertex = false; this.matScal = new Vector3(1f, 1f, 1f); this.rotationMatrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, this.matScal); this.locklocalToWorldMatrix = this.rotationMatrix; this.eRotate = true; this.oScal = base.transform.localScale; } public virtual void Update() { if (GameMain.Instance.VRMode) { return; } if (NInput.GetMouseButtonDown(0)) { if (!GizmoRender.ray_check_) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Physics.Raycast(ray, out GizmoRender.ray_hit_); GizmoRender.ui_ray_check_ = UICamera.Raycast(Input.mousePosition); GizmoRender.ray_check_ = true; GizmoRender.is_drag_ = ((GizmoRender.ray_hit_.transform == null || GizmoRender.ray_hit_.transform.gameObject.layer != 8) && !GizmoRender.ui_ray_check_); } } else if (!NInput.GetMouseButton(0)) { GizmoRender.ray_check_ = false; GizmoRender.is_drag_ = false; } } public virtual void OnDragEnd() { } public virtual void OnRenderObject() { if (GameMain.Instance.VRMode) { return; } if (!this.Visible) { if (this.beSelectedType != GizmoRender.MOVETYPE.NONE && GizmoRender.local_control_lock_) { GizmoRender.local_control_lock_ = false; } this.beSelectedType = GizmoRender.MOVETYPE.NONE; return; } GizmoRender.MOVETYPE movetype = this.beSelectedType; if (this.beSelectedType == GizmoRender.MOVETYPE.NONE) { this.panY = this.colorGreen; this.panX = this.colorRed; this.panZ = this.colorBlue; this.selX = this.colorRed; this.selY = this.colorGreen; this.selZ = this.colorBlue; this.circleX = this.colorRed; this.circleY = this.colorGreen; this.circleZ = this.colorBlue; this.moveLockVertex = false; this.oScal = base.transform.localScale; } if (!NInput.GetMouseButton(0) || !GizmoRender.is_drag_) { if (this.beSelectedType != GizmoRender.MOVETYPE.NONE && GizmoRender.local_control_lock_) { GizmoRender.local_control_lock_ = false; this.OnDragEnd(); } this.beSelectedType = GizmoRender.MOVETYPE.NONE; } else { this.planeXZ.SetNormalAndPosition(base.transform.up, base.transform.position); this.planeXY.SetNormalAndPosition(base.transform.forward, base.transform.position); this.planeYZ.SetNormalAndPosition(base.transform.right, base.transform.position); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); float distance = 0f; this.planeXZ.Raycast(ray, out distance); Vector3 vector = ray.GetPoint(distance); if (this.beSelectedType == GizmoRender.MOVETYPE.RY) { vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector); } else { vector = this.rotationMatrix.inverse.MultiplyPoint(vector); } if (this.eAxis) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.z > 0f && vector.z <= 0.3f * this.generalLens) { this.panY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.XZ; this.moveLockVertex = true; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.XZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens) { this.selX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.X; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.X && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.z = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens) { this.selZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.Z; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.Z && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.x = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } } if (this.eScal) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.x + vector.z - 0.3f * this.generalLens <= 0f) { this.panY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TXZ; this.moveLockVertex = true; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TXZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; float num = this.hitMouseMove.x + this.hitMouseMove.z; float num2 = (float)((int)(num * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(num2, 0f, num2); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens) { this.selX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TX; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TX && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.z = 0f; float x = this.hitMouseMove.x; float x2 = (float)((int)(x * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(x2, 0f, 0f); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens) { this.selZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TZ; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.x = 0f; float z = this.hitMouseMove.z; float z2 = (float)((int)(z * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(0f, 0f, z2); } } float num3 = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z); if (this.eRotate) { if (Vector3.Dot(vector, this.uForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateY && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens) { this.circleY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.RY; this.moveLockVertex = true; this.hitMouseDown = vector; this.locklocalToWorldMatrix = this.rotationMatrix; this.rotaCal = 0f; } if (this.beSelectedType == GizmoRender.MOVETYPE.RY) { this.hitMouseMove = vector; float num4 = Vector3.Dot(this.hitMouseDown.normalized, this.untransRight); float num5 = Vector3.Dot(this.hitMouseMove.normalized, this.untransRight); float num6 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized); num4 = this.SnapDot(num4, this.hitMouseDown.x, this.hitMouseDown.z); num5 = this.SnapDot(num5, this.hitMouseMove.x, this.hitMouseMove.z); num6 = Mathf.Acos(num6); if (num4 == num5) { goto IL_1C9F; } float num7 = num4 + 3.14159274f; if (num7 > 6.28318548f) { if ((num5 < 0f || num5 > num7 - 6.28318548f) && num5 <= num4) { num6 = -num6; } } else if (num5 < num4 || num5 > num7) { num6 = -num6; } if (float.IsNaN(num6)) { goto IL_1C9F; } this.rotaCal = num6 - this.rotaCal; this.DrawCam(this.colorWhite, num4, num6, GizmoRender.MOVETYPE.Y); base.transform.RotateAround(base.transform.up, -this.rotaCal); this.rotaCal = num6; } } distance = 0f; this.planeXY.Raycast(ray, out distance); vector = ray.GetPoint(distance); if (this.beSelectedType == GizmoRender.MOVETYPE.RZ) { vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector); } else { vector = this.rotationMatrix.inverse.MultiplyPoint(vector); } if (this.eAxis) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens) { this.panZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.XY; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.XY) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens) { this.selX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.X2; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.X2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.z = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens) { this.selY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.Y; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.Y && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; this.hitMouseMove.x = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } } if (this.eScal) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens && vector.x + vector.y - 0.3f * this.generalLens <= 0f) { this.panZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TXY; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TXY) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; float num8 = this.hitMouseMove.x + this.hitMouseMove.y; float num9 = (float)((int)(num8 * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(num9, num9, 0f); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens) { this.selX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TX2; this.moveLockVertex = true; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TX2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.z = 0f; float x3 = this.hitMouseMove.x; float x4 = (float)((int)(x3 * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(x4, 0f, 0f); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens) { this.selY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TY; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TY && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; this.hitMouseMove.x = 0f; float y = this.hitMouseMove.y; float y2 = (float)((int)(y * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(0f, y2, 0f); } } num3 = Mathf.Sqrt(vector.x * vector.x + vector.y * vector.y); if (this.eRotate) { if (Vector3.Dot(vector, this.fForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateZ && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens) { this.circleZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.RZ; this.moveLockVertex = true; this.hitMouseDown = vector; this.locklocalToWorldMatrix = this.rotationMatrix; this.rotaCal = 0f; } if (this.beSelectedType == GizmoRender.MOVETYPE.RZ) { this.hitMouseMove = vector; float num10 = Vector3.Dot(this.hitMouseDown.normalized, this.untransUp); float num11 = Vector3.Dot(this.hitMouseMove.normalized, this.untransUp); float num12 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized); num10 = this.SnapDot(num10, this.hitMouseDown.y, this.hitMouseDown.x); num11 = this.SnapDot(num11, this.hitMouseMove.y, this.hitMouseMove.x); num12 = Mathf.Acos(num12); if (num10 == num11) { goto IL_1C9F; } float num13 = num10 + 3.14159274f; if (num13 > 6.28318548f) { if ((num11 < 0f || num11 > num13 - 6.28318548f) && num11 <= num10) { num12 = -num12; } } else if (num11 < num10 || num11 > num13) { num12 = -num12; } if (float.IsNaN(num12)) { goto IL_1C9F; } this.rotaCal = num12 - this.rotaCal; this.DrawCam(this.colorWhite, num10, num12, GizmoRender.MOVETYPE.Z); base.transform.RotateAround(base.transform.forward, -this.rotaCal); this.rotaCal = num12; } } distance = 0f; this.planeYZ.Raycast(ray, out distance); vector = ray.GetPoint(distance); if (this.beSelectedType == GizmoRender.MOVETYPE.RX) { vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector); } else { vector = this.rotationMatrix.inverse.MultiplyPoint(vector); } if (this.eAxis) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens) { this.panX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.YZ; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.YZ) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.x = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens) { this.selZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.Z2; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.Z2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.x = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens) { this.selY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.Y2; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.Y2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; this.hitMouseMove.x = 0f; base.transform.position += base.transform.rotation * this.hitMouseMove; } } if (this.eScal) { if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens && vector.y + vector.z - 0.3f * this.generalLens <= 0f) { this.panX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TYZ; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TYZ) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.x = 0f; float num14 = this.hitMouseMove.z + this.hitMouseMove.y; float num15 = (float)((int)(num14 * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(0f, num15, num15); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens) { this.selZ = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TZ2; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TZ2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.y = 0f; this.hitMouseMove.x = 0f; float z3 = this.hitMouseMove.z; float z4 = (float)((int)(z3 * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(0f, 0f, z4); } if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens) { this.selY = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.TY2; this.hitMouseDown = vector; } if (this.beSelectedType == GizmoRender.MOVETYPE.TY2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f)) { this.hitMouseMove = vector - this.hitMouseDown; this.hitMouseMove.z = 0f; this.hitMouseMove.x = 0f; float y3 = this.hitMouseMove.y; float y4 = (float)((int)(y3 * 10f)) / 10f; base.transform.localScale = this.oScal + new Vector3(0f, y4, 0f); } } num3 = Mathf.Sqrt(vector.z * vector.z + vector.y * vector.y); if (this.eRotate) { if (Vector3.Dot(vector, this.rForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateX && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens) { this.circleX = this.colorFan; this.beSelectedType = GizmoRender.MOVETYPE.RX; this.moveLockVertex = true; this.hitMouseDown = vector; this.locklocalToWorldMatrix = this.rotationMatrix; this.rotaCal = 0f; } if (this.beSelectedType == GizmoRender.MOVETYPE.RX) { this.hitMouseMove = vector; float num16 = Vector3.Dot(this.hitMouseDown.normalized, this.untransForward); float num17 = Vector3.Dot(this.hitMouseMove.normalized, this.untransForward); float num18 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized); num16 = this.SnapDot(num16, this.hitMouseDown.z, this.hitMouseDown.y); num17 = this.SnapDot(num17, this.hitMouseMove.z, this.hitMouseMove.y); num18 = Mathf.Acos(num18); if (num16 != num17) { float num19 = num16 + 3.14159274f; if (num19 > 6.28318548f) { if ((num17 < 0f || num17 > num19 - 6.28318548f) && num17 <= num16) { num18 = -num18; } } else if (num17 < num16 || num17 > num19) { num18 = -num18; } if (!float.IsNaN(num18)) { this.rotaCal = num18 - this.rotaCal; this.DrawCam(this.colorWhite, num16, num18, GizmoRender.MOVETYPE.X); base.transform.RotateAround(base.transform.right, -this.rotaCal); this.rotaCal = num18; } } } } } IL_1C9F: if (movetype == GizmoRender.MOVETYPE.NONE && this.beSelectedType != GizmoRender.MOVETYPE.NONE && !GizmoRender.local_control_lock_) { GizmoRender.local_control_lock_ = true; } this.RenderGizmos(); } public void RenderGizmos() { this.Dir = Camera.main.transform.position - base.transform.position; float magnitude = this.Dir.magnitude; this.generalLens = -2f * Mathf.Tan(0.5f * Camera.main.fieldOfView) * magnitude / 50f; this.generalLens *= this.offsetScale; this.Dir.Normalize(); GL.PushMatrix(); this.rotationMatrix = base.transform.localToWorldMatrix; this.rotationMatrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, this.matScal); GL.MultMatrix(this.rotationMatrix); this.lineMaterial.SetPass(0); if (this.eRotate) { Vector3 rhs = base.transform.InverseTransformPoint(Camera.main.transform.position); Vector3 vector = Vector3.Cross(this.untransRight, rhs); vector.Normalize(); vector *= this.generalLens; Vector3 vector2 = Vector3.Cross(vector, this.untransRight); vector2.Normalize(); vector2 *= this.generalLens; if (this.VisibleRotateX && GizmoRender.UIVisible) { this.DrawCircleHalf(this.circleX, vector, vector2); } this.rForward = vector2; vector = Vector3.Cross(this.untransUp, rhs); vector.Normalize(); vector *= this.generalLens; vector2 = Vector3.Cross(vector, this.untransUp); vector2.Normalize(); vector2 *= this.generalLens; if (this.VisibleRotateY && GizmoRender.UIVisible) { this.DrawCircleHalf(this.circleY, vector, vector2); } this.uForward = vector2; vector = Vector3.Cross(this.untransForward, rhs); vector.Normalize(); vector *= this.generalLens; vector2 = Vector3.Cross(vector, this.untransForward); vector2.Normalize(); vector2 *= this.generalLens; if (this.VisibleRotateZ && GizmoRender.UIVisible) { this.DrawCircleHalf(this.circleZ, vector, vector2); } this.fForward = vector2; } if (this.eAxis) { this.DrawAxis(this.untransRight * this.generalLens, this.untransUp, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selX); this.DrawAxis(this.untransUp * this.generalLens, this.untransRight, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selY); this.DrawAxis(this.untransForward * this.generalLens, this.untransRight, this.untransUp, 0.04f * this.generalLens, 0.9f, this.selZ); this.DrawQuad(0.3f * this.generalLens, false, this.untransForward, this.untransUp, this.panX); this.DrawQuad(0.3f * this.generalLens, false, this.untransRight, this.untransForward, this.panY); this.DrawQuad(0.3f * this.generalLens, false, this.untransRight, this.untransUp, this.panZ); } if (this.eScal) { this.DrawAxis(this.untransRight * this.generalLens, this.untransUp, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selX); this.DrawAxis(this.untransUp * this.generalLens, this.untransRight, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selY); this.DrawAxis(this.untransForward * this.generalLens, this.untransRight, this.untransUp, 0.04f * this.generalLens, 0.9f, this.selZ); this.DrawTri(0.3f * this.generalLens, false, this.untransForward, this.untransUp, this.panX); this.DrawTri(0.3f * this.generalLens, false, this.untransRight, this.untransForward, this.panY); this.DrawTri(0.3f * this.generalLens, false, this.untransRight, this.untransUp, this.panZ); } GL.PopMatrix(); } private void DrawCam(Color col, float sang, float eng, GizmoRender.MOVETYPE dtype) { GL.PushMatrix(); this.rotationMatrix = this.locklocalToWorldMatrix; GL.MultMatrix(this.rotationMatrix); this.lineMaterial.SetPass(0); GL.Begin(4); GL.Color(col); if (dtype != GizmoRender.MOVETYPE.X) { if (dtype != GizmoRender.MOVETYPE.Y) { if (dtype == GizmoRender.MOVETYPE.Z) { for (int i = 0; i < 20; i++) { float f = sang + eng * (float)i / 20f; GL.Vertex3(0f, 0f, 0f); GL.Vertex3(Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens, 0f); f = sang + eng * (float)(i + 1) / 20f; GL.Vertex3(Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens, 0f); } } } else { for (int j = 0; j < 20; j++) { float f = sang + eng * (float)j / 20f; GL.Vertex3(0f, 0f, 0f); GL.Vertex3(Mathf.Cos(f) * this.generalLens, 0f, Mathf.Sin(f) * this.generalLens); f = sang + eng * (float)(j + 1) / 20f; GL.Vertex3(Mathf.Cos(f) * this.generalLens, 0f, Mathf.Sin(f) * this.generalLens); } } } else { for (int k = 0; k < 20; k++) { float f = sang + eng * (float)k / 20f; GL.Vertex3(0f, 0f, 0f); GL.Vertex3(0f, Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens); f = sang + eng * (float)(k + 1) / 20f; GL.Vertex3(0f, Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens); } } GL.End(); GL.PopMatrix(); } private void DrawCircle(Color col, Vector3 vtx, Vector3 vty) { GL.Begin(1); GL.Color(col); for (int i = 0; i < 100; i++) { Vector3 a = vtx * Mathf.Cos(0.06283186f * (float)i); a += vty * Mathf.Sin(0.06283186f * (float)i); GL.Vertex3(a.x, a.y, a.z); a = vtx * Mathf.Cos(0.06283186f * (float)(i + 1)); a += vty * Mathf.Sin(0.06283186f * (float)(i + 1)); GL.Vertex3(a.x, a.y, a.z); } GL.End(); } private float SnapDot(float dot, float x, float y) { float result; if (dot >= 0f) { if (y > 0f) { result = Mathf.Acos(dot); } else { result = 6.28318548f - Mathf.Acos(dot); } } else if (y > 0f) { result = Mathf.Acos(dot); } else { result = 6.28318548f - Mathf.Acos(dot); } return result; } private void DrawCircleHalf(Color col, Vector3 vtx, Vector3 vty) { GL.Begin(1); GL.Color(col); for (int i = 0; i < 100; i++) { Vector3 a = vtx * Mathf.Cos(0.03141593f * (float)i); a += vty * Mathf.Sin(0.03141593f * (float)i); GL.Vertex3(a.x, a.y, a.z); a = vtx * Mathf.Cos(0.03141593f * (float)(i + 1)); a += vty * Mathf.Sin(0.03141593f * (float)(i + 1)); GL.Vertex3(a.x, a.y, a.z); } GL.End(); } private void DrawAxis(Vector3 axis, Vector3 vtx, Vector3 vty, float fct, float fct2, Color col) { GL.Begin(1); GL.Color(col); GL.Vertex3(0f, 0f, 0f); GL.Vertex(axis); GL.End(); GL.Begin(4); for (int i = 0; i <= 30; i++) { Vector3 vector = vtx * Mathf.Cos(0.209439516f * (float)i) * fct; vector += vty * Mathf.Sin(0.209439516f * (float)i) * fct; vector += axis * fct2; GL.Vertex(vector); vector = vtx * Mathf.Cos(0.209439516f * (float)(i + 1)) * fct; vector += vty * Mathf.Sin(0.209439516f * (float)(i + 1)) * fct; vector += axis * fct2; GL.Vertex(vector); GL.Vertex(axis); } GL.End(); } private void DrawAxisS(Vector3 axis, Color col) { GL.Begin(1); GL.Color(col); GL.Vertex3(0f, 0f, 0f); GL.Vertex(axis); GL.End(); } private void DrawFan(Vector3 vtx, Vector3 vty, float ng) { for (int i = 0; i <= 50; i++) { GL.Begin(4); GL.Color(this.colorFan); Vector3 vector = vtx * Mathf.Cos(ng / 50f * (float)i); vector += vty * Mathf.Sin(ng / 50f * (float)i); GL.Vertex(vector); vector = vtx * Mathf.Cos(ng / 50f * (float)(i + 1)); vector += vty * Mathf.Sin(ng / 50f * (float)(i + 1)); GL.Vertex(vector); GL.Vertex(Vector3.zero); GL.End(); } } private void DrawQuad(float size, bool bSelected, Vector3 axisU, Vector3 axisV, Color col) { col.a = 0.3f; Vector3[] array = new Vector3[] { Vector3.zero, axisU * size, (axisU + axisV) * size, axisV * size }; GL.Begin(7); if (!bSelected) { GL.Color(col); } else { GL.Color(this.colorWhite); } GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[2]); GL.Vertex(array[3]); GL.End(); col.a = 1f; if (!bSelected) { GL.Color(col); } else { GL.Color(this.colorWhite); } GL.Begin(1); GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[1]); GL.Vertex(array[2]); GL.Vertex(array[2]); GL.Vertex(array[3]); GL.Vertex(array[3]); GL.Vertex(array[0]); GL.End(); } private void DrawTri(float size, bool bSelected, Vector3 axisU, Vector3 axisV, Color col) { col.a = 0.3f; Vector3[] array = new Vector3[] { Vector3.zero, axisU, axisV }; array[1] *= size; array[2] *= size; GL.Begin(4); if (!bSelected) { GL.Color(col); } else { GL.Color(this.colorWhite); } GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[2]); GL.End(); col.a = 1f; if (!bSelected) { GL.Color(col); } else { GL.Color(this.colorWhite); } GL.Begin(1); GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[1]); GL.Vertex(array[2]); GL.Vertex(array[2]); GL.Vertex(array[0]); GL.End(); } private void DrawCube(float size, bool bSelected, Vector3 center, Vector3 axisU, Vector3 axisV, Color col, GizmoRender.MOVETYPE move) { Vector3[] array = new Vector3[8]; center.x -= size / 2f; center.y -= size / 2f; center.z -= size / 2f; array[0] = center; array[1] = center + axisU * size; array[2] = center + (axisU + axisV) * size; array[3] = center + axisV * size; array[4] = array[0]; if (move == GizmoRender.MOVETYPE.X) { Vector3[] array2 = array; int num = 4; array2[num].x = array2[num].x + size; } if (move == GizmoRender.MOVETYPE.Y) { Vector3[] array3 = array; int num2 = 4; array3[num2].y = array3[num2].y + size; } if (move == GizmoRender.MOVETYPE.Z) { Vector3[] array4 = array; int num3 = 4; array4[num3].z = array4[num3].z + size; } array[5] = array[1]; if (move == GizmoRender.MOVETYPE.X) { Vector3[] array5 = array; int num4 = 5; array5[num4].x = array5[num4].x + size; } if (move == GizmoRender.MOVETYPE.Y) { Vector3[] array6 = array; int num5 = 5; array6[num5].y = array6[num5].y + size; } if (move == GizmoRender.MOVETYPE.Z) { Vector3[] array7 = array; int num6 = 5; array7[num6].z = array7[num6].z + size; } array[6] = array[2]; if (move == GizmoRender.MOVETYPE.X) { Vector3[] array8 = array; int num7 = 6; array8[num7].x = array8[num7].x + size; } if (move == GizmoRender.MOVETYPE.Y) { Vector3[] array9 = array; int num8 = 6; array9[num8].y = array9[num8].y + size; } if (move == GizmoRender.MOVETYPE.Z) { Vector3[] array10 = array; int num9 = 6; array10[num9].z = array10[num9].z + size; } array[7] = array[3]; if (move == GizmoRender.MOVETYPE.X) { Vector3[] array11 = array; int num10 = 7; array11[num10].x = array11[num10].x + size; } if (move == GizmoRender.MOVETYPE.Y) { Vector3[] array12 = array; int num11 = 7; array12[num11].y = array12[num11].y + size; } if (move == GizmoRender.MOVETYPE.Z) { Vector3[] array13 = array; int num12 = 7; array13[num12].z = array13[num12].z + size; } GL.Begin(7); if (!bSelected) { GL.Color(col); } else { GL.Color(this.colorWhite); } GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[2]); GL.Vertex(array[3]); GL.Vertex(array[4]); GL.Vertex(array[5]); GL.Vertex(array[6]); GL.Vertex(array[7]); GL.Vertex(array[1]); GL.Vertex(array[5]); GL.Vertex(array[6]); GL.Vertex(array[2]); GL.Vertex(array[0]); GL.Vertex(array[4]); GL.Vertex(array[7]); GL.Vertex(array[3]); GL.Vertex(array[0]); GL.Vertex(array[1]); GL.Vertex(array[5]); GL.Vertex(array[4]); GL.Vertex(array[3]); GL.Vertex(array[2]); GL.Vertex(array[6]); GL.Vertex(array[7]); GL.End(); } public static bool global_control_lock; private static bool local_control_lock_; public Material lineMaterial; private Vector3 untransRight; private Vector3 untransUp; private Vector3 untransForward; private Vector3 Dir; private Color colorRed; private Color colorGreen; private Color colorBlue; private Color colorFan; private Color colorWhite; private Color colorLine; private Color colorWire; private Color selX; private Color selY; private Color selZ; private Color panY; private Color panX; private Color panZ; private Color circleX; private Color circleY; private Color circleZ; private Plane planeXZ; private Plane planeYZ; private Plane planeXY; public float lineSelectedThick = 0.04f; public float lineRSelectedThick = 0.1f; private float generalLens = 1f; private GizmoRender.MOVETYPE beSelectedType; private Vector3 hitMouseDown; private Vector3 hitMouseMove; private bool moveLockVertex; private Matrix4x4 locklocalToWorldMatrix; private float rotaCal; private Vector3 matScal; private Matrix4x4 rotationMatrix; private Vector3 uForward; private Vector3 rForward; private Vector3 fForward; public bool Visible = true; public bool VisibleRotateX = true; public bool VisibleRotateY = true; public bool VisibleRotateZ = true; public static bool UIVisible = true; public bool eAxis; public bool eRotate; public bool eScal; private Vector3 oScal; private static RaycastHit ray_hit_; private static bool ray_check_; private static bool ui_ray_check_; private static bool is_drag_; public float offsetScale = 1f; private enum MOVETYPE { NONE, X, X2, Y, Y2, Z, Z2, XZ, YZ, XY, RX, RY, RZ, TX, TY, TZ, TX2, TY2, TZ2, TXY, TXZ, TYZ } }