void Start() { SetGizmos(); _setTarget = new SetTargetCommand(this, selectedMaterial); _deleteModulationItem = new DeleteModulationItem(this); EventsManager.ItemTransformation += ClickUpdate; }
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); } }
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); } } } }
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); }
public MoveTool() { _tog = new TurnOnGizmoCommand(); _st = new SetTransformationCommand(); }