Exemple #1
0
    //*****//

    private void DoScaleControls()
    {
        AddControl(ControlType.ScaleCenter, MyHandleUtility.DistanceToCircle(transform.position, _handleSize * 0.15f));
        AddControl(ControlType.ScaleX, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.right * _handleSize));
        AddControl(ControlType.ScaleX, MyHandleUtility.DistanceToCircle(transform.position + transform.right * _handleSize, _handleSize * 0.2f));
        AddControl(ControlType.ScaleY, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.up * _handleSize));
        AddControl(ControlType.ScaleY, MyHandleUtility.DistanceToCircle(transform.position + transform.up * _handleSize, _handleSize * 0.2f));
        AddControl(ControlType.ScaleZ, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.forward * _handleSize));
        AddControl(ControlType.ScaleZ, MyHandleUtility.DistanceToCircle(transform.position + transform.forward * _handleSize, _handleSize * 0.2f));

        _currentControl = NearestControl;
        if (_currentControl != ControlType.None)
        {
            _freezeObjectPicking  = true;
            _currentMousePosition = _startMousePosition = Event.current.mousePosition;

            if (CurrentControl == ControlType.ScaleCenter)
            {
                _scaleValueDrag  = 0.0f;
                _startScaleValue = transform.localScale.x;
            }
            else if (CurrentControl == ControlType.ScaleX)
            {
                _startScaleValue = transform.localScale.x;
            }
            else if (CurrentControl == ControlType.ScaleY)
            {
                _startScaleValue = transform.localScale.y;
            }
            else if (CurrentControl == ControlType.ScaleZ)
            {
                _startScaleValue = transform.localScale.z;
            }
        }
    }
Exemple #2
0
    //*****//

    private void DoTranslateControls()
    {
        AddControl(ControlType.TranslateX, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.right * _handleSize));
        AddControl(ControlType.TranslateX, MyHandleUtility.DistanceToCircle(transform.position + transform.right * _handleSize, _handleSize * 0.2f));
        AddControl(ControlType.TranslateY, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.up * _handleSize));
        AddControl(ControlType.TranslateY, MyHandleUtility.DistanceToCircle(transform.position + transform.up * _handleSize, _handleSize * 0.2f));
        AddControl(ControlType.TranslateZ, MyHandleUtility.DistanceToLine(transform.position, transform.position + transform.forward * _handleSize));
        AddControl(ControlType.TranslateZ, MyHandleUtility.DistanceToCircle(transform.position + transform.forward * _handleSize, _handleSize * 0.2f));

        _currentControl = NearestControl;
        if (_currentControl != ControlType.None)
        {
            _freezeObjectPicking    = true;
            _currentControl         = NearestControl;
            _translateStartPosition = transform.position;
            _currentMousePosition   = _startMousePosition = Event.current.mousePosition;
        }
    }