Hi,
I have a mini-game, that once the scene begins i want to make the cursor invisible' in the top two thirds of the screen and visible in the bottom third. My coding is poor so any ideas?
OR
the cursor is invisible for the entire scene but still 'there' if you get me?
Thanks!
Comments
Which cursor do you want to change? The main cursor? Somethine like this ought to do it:
private Texture2D normalTexture;
private void Start ()
{
normalTexture = AC.KickStarter.cursorManager.pointerIcon.texture;
}
private void Update ()
{
float mouseHeight = Input.mousePosition.y;
float screenHeight = Screen.height;
if (mousePosition.y / screenHeight) < 0.33f)
{
// Show cursor
AC.KickStarter.cursorManager.pointerIcon.texture = normalTexture;
}
else
{
// Hide cursor
AC.KickStarter.cursorManager.pointerIcon.texture = null;
}
}
Make a new C# script and replace that with the default Start/Update functions.
if (mousePosition.y / screenHeight) < 0.33f)
with
if (mouseHeight / screenHeight < 0.33f)
What line does the error refer to? Be sure to place the code inside the class block.
private Texture2D normalTexture;
If you need help with understanding how C# scripts work, Unity's own tutorials are a better place to start.
adventurecreator.org/files/NewCursor.cs
{
// Show cursor
AC.KickStarter.cursorManager.pointerIcon.texture = normalTexture;
}
public class RotateCursor : MonoBehaviour {
private Texture2D normalTexture;
private void Start ()
{
normalTexture = AC.KickStarter.cursorManager.pointerIcon.texture;
}
private void Update ()
{
{
// Rotate the object around its local X axis at 1 degree per second
transform.Rotate (Vector3.right * Time.deltaTime);
// ...also rotate around the World's Y axis
transform.Rotate (Vector3.up * Time.deltaTime, Space.World);
}
}
}
If you want to have the cursor rotate, you'll have to override the AC cursor with a GameObject sprite or some other in-scene graphic.
The included World Space Cursor Example script can be attached to an object in your scene to take the place of your cursor - you could duplicate it and amend to suit your own needs.