- Home /
How to enable cursor on trigger
I created a canvas that would appear once the player hits an AI. The only problem is the mouse won't show. Here is my current script. { public Canvas myCanvas;
private void OnTriggerEnter(Collider AI)
{
if (AI.gameObject.name == "It")
{
myCanvas.GetComponent<CanvasGroup>().alpha = 1;
gameObject.SetActive(false);
Cursor.visible = true;
}
}
private void OnTriggerExit(Collider other)
{
myCanvas.GetComponent<CanvasGroup>().alpha = 0;
}
}
Have you checked if OnTriggerEnter is being called?
If not, consider checking the required components for it to be called.
If yes, Does it work when you remove your condition and trigger to any colliders?
The components are correct. I removed the condition and used another trigger and the mouse still won't show up.
Wait never $$anonymous$$d I fixed the problem. I had a cursor lock on in my walk script which disabled the mouse. Thank you for the help.
Answer by EmreB05 · Nov 21, 2017 at 08:29 PM
Heres the API page: https://docs.unity3d.com/ScriptReference/Cursor-visible.html
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Use trigger with player but have a collider with everything else? 3 Answers
Mouse cursor colliding with particles how ??? 1 Answer
Stop object colliders (non-mesh) bouncing on collision 1 Answer
How can I let a trigger detect if a collider is inside (at start) 1 Answer