Trying to make the Cursor Invisible when a UI button is pressed
Hello, so I am trying to make a Horror game and when the main menu button is pressed to make the cursor invisible. Except I have looked everywhere and I can't get it to work. Here is the code I am using`using UnityEngine; using System.Collections;
public class Cursor : MonoBehaviour {
%|-496017692_2|% %|-353848803_3|% UnityEngine.Cursor.visible = true; %|135087020_5|% void onClick() { %|1332819508_8|% %|-1904072890_9|%
}
And the OnClick is connected to a button like in this picture I am using C# for this and I would appreciate it if whoever helps me can use C# too. Thanks!`
Answer by Ran-Quan · Mar 24, 2017 at 03:29 AM
The OnClick event on your button isn't setup correctly. What you're doing is setting Cursor.name
to a string "onClick()"
. You should make your Cursor
class's onClick
method public, and then choose Cursor
>onClick
in your button's inspector.