- Home /
Cursor Texture Bug
Hello, I made myself a custom cursor for my game but when I press play a weird texture pop up rather then the one I made here is my code if it can help Btw(it also include some of my game code just dont mind it).
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BuildingGrid : MonoBehaviour {
public GameObject HullBlock;
public Texture2D HullBlocCursor;
public Texture2D NormalCursor;
public CursorMode CursorMode = CursorMode.Auto;
public Vector2 HotSpot = Vector2.zero;
public float HullToggle = 0;
void Start()
{
Cursor.SetCursor(NormalCursor, HotSpot, CursorMode);
}
void Update()
{
//MousePosition
var MousePos = Input.mousePosition;
MousePos.z = 0.2f;
var ObjectPos = Camera.main.ScreenToWorldPoint(MousePos);
//-------------------------------------------------------
if ((Input.GetKeyDown(KeyCode.Alpha1)) && (HullToggle == 0))
{
HullToggle = 1;
Cursor.SetCursor(HullBlocCursor, HotSpot, CursorMode);
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Cursor.SetCursor(NormalCursor, HotSpot, CursorMode);
}
}
}
Comment
you can put you cursor texture in edit>project settings>player and then add the texture to the box default cursor
make sure to change the texture type to cursor
Your answer
Follow this Question
Related Questions
Mouse cursor is giant in Mac builds. 1 Answer
Cursor disappearing in webplayer 1 Answer
Camera.main.ScreenToWorldPoint not working 0 Answers