- Home /
Question by
JoyGamers · Jul 18, 2019 at 07:20 AM ·
c#editorscene-switching
Custom cursor under text button
I watched Blackthornprod's tutorial: https://www.youtube.com/watch?v=cCKlMAwvQcI&t=20s And then I added some buttons
My game is 2D. And the buttons are under the mouse cursor when I want to click them. The buttons does work but the mouse goes under the text/button.These are the elements. And the scripts.The first one is for the mouse custom cursor. And the second one is for changing scenes, I don't know if it helps. Pls HELP Quickly!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mouseCursor : MonoBehaviour
{
private SpriteRenderer rend;
public Sprite handCursor;
public Sprite normalCursor;
public GameObject clickEffect;
void Start()
{
Cursor.visible = false;
rend = GetComponent<SpriteRenderer>();
}
void Update ()
{
Vector2 cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = cursorPos;
if(Input.GetMouseButtonDown(0))
{
rend.sprite = handCursor;
Instantiate(clickEffect, transform.position, Quaternion.identity);
} else if(Input.GetMouseButtonUp(0))
{
rend.sprite = normalCursor;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class menuStart : MonoBehaviour
{
public void ChangeScene(string sceneName)
{
Application.LoadLevel(sceneName);
}
}
Comment
Your answer
