Hello, I am using FPSController from Unity standard assets.
Sometimes I need to switch from FPS mode to drawing mode, in which I use my mouse to draw lines on the screen.
I tried the following code in Update()
:
if (state == States.Drawing) {
if (Crosshair != null) Crosshair.SetActive(false);
if (fpsController != null) fpsController.enabled = false;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else {
if (Crosshair != null) Crosshair.SetActive(true);
if (fpsController != null) fpsController.enabled = true;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
Where fpsController is the reference to the FPSController component.
When I enter drawing mode, my mouse is released, but after a click ,it’s captured again and the fpsController is still working. I suspect that fpsController.enabled = false
is not working at all.
Is there better way to do this?