public void OnSceneGUI() { bool flag = GUIUtility.hotControl == this.m_HandleControlID; CapsuleCollider target = (CapsuleCollider)this.target; Color color = Handles.color; Handles.color = !target.enabled ? Handles.s_ColliderHandleColorDisabled : Handles.s_ColliderHandleColor; bool enabled = GUI.enabled; if (!this.editingCollider && !flag) { GUI.enabled = false; Handles.color = new Color(1f, 0.0f, 0.0f, 1f / 1000f); } Vector3 capsuleExtents = ColliderUtil.GetCapsuleExtents(target); float num1 = capsuleExtents.y + 2f * capsuleExtents.x; float x = capsuleExtents.x; Matrix4x4 capsuleTransform = ColliderUtil.CalculateCapsuleTransform(target); int hotControl = GUIUtility.hotControl; float height = target.height; Vector3 localPos = Vector3.left * num1 * 0.5f; float num2 = CapsuleColliderEditor.SizeHandle(localPos, Vector3.left, capsuleTransform, true); if (!GUI.changed) { num2 = CapsuleColliderEditor.SizeHandle(-localPos, Vector3.right, capsuleTransform, true); } if (GUI.changed) { float num3 = num1 / target.height; height += num2 / num3; } float radius = target.radius; float num4 = CapsuleColliderEditor.SizeHandle(Vector3.forward * x, Vector3.forward, capsuleTransform, true); if (!GUI.changed) { num4 = CapsuleColliderEditor.SizeHandle(-Vector3.forward * x, -Vector3.forward, capsuleTransform, true); } if (!GUI.changed) { num4 = CapsuleColliderEditor.SizeHandle(Vector3.up * x, Vector3.up, capsuleTransform, true); } if (!GUI.changed) { num4 = CapsuleColliderEditor.SizeHandle(-Vector3.up * x, -Vector3.up, capsuleTransform, true); } if (GUI.changed) { float num3 = Mathf.Max(capsuleExtents.z / target.radius, capsuleExtents.x / target.radius); radius += num4 / num3; } if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0) { this.m_HandleControlID = GUIUtility.hotControl; } if (GUI.changed) { Undo.RecordObject((Object)target, "Modify Capsule Collider"); target.radius = Mathf.Max(radius, 1E-05f); target.height = Mathf.Max(height, 1E-05f); } Handles.color = color; GUI.enabled = enabled; }
public void OnSceneGUI() { bool flag = GUIUtility.hotControl == this.m_HandleControlID; CapsuleCollider capsuleCollider = (CapsuleCollider)base.target; Color color = Handles.color; if (capsuleCollider.enabled) { Handles.color = Handles.s_ColliderHandleColor; } else { Handles.color = Handles.s_ColliderHandleColorDisabled; } bool enabled = GUI.enabled; if (!base.editingCollider && !flag) { GUI.enabled = false; Handles.color = new Color(1f, 0f, 0f, 0.001f); } Vector3 capsuleExtents = ColliderUtil.GetCapsuleExtents(capsuleCollider); float num = capsuleExtents.y + 2f * capsuleExtents.x; float x = capsuleExtents.x; Matrix4x4 matrix = ColliderUtil.CalculateCapsuleTransform(capsuleCollider); int hotControl = GUIUtility.hotControl; float num2 = capsuleCollider.height; Vector3 vector = Vector3.left * num * 0.5f; float num3 = CapsuleColliderEditor.SizeHandle(vector, Vector3.left, matrix, true); if (!GUI.changed) { num3 = CapsuleColliderEditor.SizeHandle(-vector, Vector3.right, matrix, true); } if (GUI.changed) { float num4 = num / capsuleCollider.height; num2 += num3 / num4; } float num5 = capsuleCollider.radius; num3 = CapsuleColliderEditor.SizeHandle(Vector3.forward * x, Vector3.forward, matrix, true); if (!GUI.changed) { num3 = CapsuleColliderEditor.SizeHandle(-Vector3.forward * x, -Vector3.forward, matrix, true); } if (!GUI.changed) { num3 = CapsuleColliderEditor.SizeHandle(Vector3.up * x, Vector3.up, matrix, true); } if (!GUI.changed) { num3 = CapsuleColliderEditor.SizeHandle(-Vector3.up * x, -Vector3.up, matrix, true); } if (GUI.changed) { float num6 = Mathf.Max(capsuleExtents.z / capsuleCollider.radius, capsuleExtents.x / capsuleCollider.radius); num5 += num3 / num6; } if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0) { this.m_HandleControlID = GUIUtility.hotControl; } if (GUI.changed) { Undo.RecordObject(capsuleCollider, "Modify Capsule Collider"); capsuleCollider.radius = Mathf.Max(num5, 1E-05f); capsuleCollider.height = Mathf.Max(num2, 1E-05f); } Handles.color = color; GUI.enabled = enabled; }