Пример #1
0
 void Start()
 {
     SetGizmos();
     _setTarget                        = new SetTargetCommand(this, selectedMaterial);
     _deleteModulationItem             = new DeleteModulationItem(this);
     EventsManager.ItemTransformation += ClickUpdate;
 }
Пример #2
0
    public void ClickUpdate(RaycastHit hit, Vector2 mousePosition, Camera viewportCamera)
    {
        var command = HandleInput(hit, mousePosition, viewportCamera);

        if (command != null)
        {
            _hit     = hit;
            _command = command;
            command.Execute(this, _activeTool, hit);
        }
    }
Пример #3
0
    void Update()
    {
        if (testing)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                var command = HandleInput(hit, Input.mousePosition, Camera.main);
                if (command != null)
                {
                    _hit     = hit;
                    _command = command;
                    command.Execute(this, _activeTool, hit);
                }
            }
        }
    }
Пример #4
0
    EditModulationCommand HandleInput(RaycastHit hit, Vector2 mousePosition, Camera viewportCamera)
    {
        EditModulationCommand command = null;

        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            return(_deleteModulationItem);
        }

        switch (state)
        {
        case State.SET_TARGET:
            if (Input.GetMouseButtonDown(0))
            {
                command = _setTarget;
            }
            if (Input.GetMouseButtonUp(0))
            {
                command = _activeTool.TurnOnGizmo;
            }
            break;

        case State.SET_TRANSFORMATION:
            if (Input.GetMouseButtonDown(0))
            {
                command = _setTarget;
                _activeTool.DisableInactiveAxis(Target, hit, mousePosition, viewportCamera);
            }
            if (Input.GetMouseButton(0))
            {
                _activeTool.UpdateTransformation(Target, hit, mousePosition, viewportCamera);
            }
            if (Input.GetMouseButtonUp(0))
            {
                _activeTool.EnableAllAxis();
            }
            break;
        }

        return(command);
    }
Пример #5
0
 public MoveTool()
 {
     _tog = new TurnOnGizmoCommand();
     _st  = new SetTransformationCommand();
 }