Пример #1
0
    //*****//

    public void BeginHandle()
    {
        _handleSize = MyHandleUtility.GetHandleSize(transform.position);

        if (Event.current.type == EventType.Layout)
        {
            _nearestDistance = 5f;
            _nearestControl  = ControlType.None;
        }
    }
Пример #2
0
    //*****//

    private void OnRenderObject()
    {
        if (!_enabled || Camera.current != Camera.main)
        {
            return;
        }

        _handleSize = MyHandleUtility.GetHandleSize(transform.position);

        if (GetComponent <MeshRenderer>() && GetComponent <MeshRenderer>().enabled)
        {
            MyHandleUtility.DrawWireMesh(GetComponent <MeshFilter>().sharedMesh, transform, new Color(0.5f, 0.8f, 0.5f));
        }
        else if (GetComponent <SphereCollider>() && GetComponent <SphereCollider>().enabled)
        {
            Color color          = new Color(0.5f, 0.8f, 0.5f);
            var   sphereCollider = GetComponent <SphereCollider>();

            Vector3    lossyScale = sphereCollider.transform.lossyScale;
            float      num1       = Mathf.Max(Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z));
            float      radius     = Mathf.Max(Mathf.Abs(num1 * sphereCollider.radius), 1E-05f);
            Vector3    position   = sphereCollider.transform.TransformPoint(sphereCollider.center);
            Quaternion rotation   = sphereCollider.transform.rotation;
            MyHandleUtility.DoRadiusHandle(rotation, position, radius, color);
        }

        switch (_state)
        {
        case HandleSelectionState.Scale:
            DrawScaleHandle();
            break;

        case HandleSelectionState.Rotate:
            DrawRotateHandle();
            break;

        case HandleSelectionState.Translate:
            DrawTranslateHandle();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }