Disable MouseLook/Re-Enable Mouse Visibility?

I am still very new to Unity, and scripting as a whole, so bear with me.

I have a simple First Person Controller game (cross-hair at center acts as mouse, mouse cursor is hidden), where essentially when the character clicks on the correct answer, I have a Canvas pop up that says they got it correct. This is where I want the game to end, but the player is still able to click and move around the environment even with the canvas in the way. Is there an easy way to disable this? Or better yet - is there a way to have a REPLAY button pop up and have it clickable with the mouse re-enabled?

Please help, and thank you in advance!

Yes. You need to store references to any scripts that take in input for the world (e.g. MouseLook, FirstPersonController, etc.). Then, when you open your canvas, you can just set their enabled property to false. If you have a replay button, just have it set them to true again and remove the canvas.

1 Like

Thanks for the input! Can you elaborate on how to “store references?” I’m kind of flying by the seat of my pants on scripting. :slight_smile:

Depends on the language you are using.

In C#, you just create a public variable of the correct type, then set it’s value in the inspector in Unity.

1 Like

Could you show me an example?

I’m just confused about how to disable a script - as opposed to like a GameObject.

public Rigidbody MyVariable;

MyVariable.enabled = value;