UnityEditor.CapsuleColliderEditor.SizeHandle C# (CSharp) Method

SizeHandle() private static method

private static SizeHandle ( Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle ) : float
localPos Vector3
localPullDir Vector3
matrix UnityEngine.Matrix4x4
isEdgeHandle bool
return float
        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            float num3;
            Vector3 rhs = matrix.MultiplyVector(localPullDir);
            Vector3 position = matrix.MultiplyPoint(localPos);
            float handleSize = HandleUtility.GetHandleSize(position);
            bool changed = GUI.changed;
            GUI.changed = false;
            Color color = Handles.color;
            float num2 = 0f;
            if (isEdgeHandle)
            {
                num2 = Mathf.Cos(0.7853982f);
            }
            if (Camera.current.orthographic)
            {
                num3 = Vector3.Dot(-Camera.current.transform.forward, rhs);
            }
            else
            {
                Vector3 vector3 = Camera.current.transform.position - position;
                num3 = Vector3.Dot(vector3.normalized, rhs);
            }
            if (num3 < -num2)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }
            if (<>f__mg$cache0 == null)
            {
                <>f__mg$cache0 = new Handles.CapFunction(Handles.DotHandleCap);

Usage Example

        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;
        }
All Usage Examples Of UnityEditor.CapsuleColliderEditor::SizeHandle