Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Change the mouse picture into the one you want in unity 3D

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Today I looked at how to change the picture of the mouse in unity. This is because I have seen some games with their own mouse style before, like some with a sword and some with a hand. Needless to say, first download a mouse-style picture, as long as the picture is supported by U3D can be like png. The idea is to use our own picture instead of a mouse-style picture.

The code is as follows (on Cube)

Using System.Collections

Using System.Collections.Generic

Using UnityEngine

Public class NewBehaviourScript: MonoBehaviour {

Public Texture2D mousetexture;// custom mouse styl

Public Texture2D mouse_time;// Custom Styl

/ / Use this for initialization

Void Start () {

GetComponent () .material.color = Color.grey;// modifies the color of Cube

Mousetexture = Resources.Load ("cur"); / / load the picture of the sword

Mouse_time = Resources.Load ("tu"); / / load the picture of the sword

Cursor.SetCursor (mousetexture, Vector2.zero, CursorMode.Auto); / / the icon initialized to the sword

}

/ / Update is called once per frame

Void Update () {

}

Private void OnMouseOver ()

{

Cursor.SetCursor (mouse_time, Vector2.zero, CursorMode.Auto); / / switch mouse style when entering

}

Private void OnMouseExit ()

{

Cursor.SetCursor (mousetexture, Vector2.zero, CursorMode.Auto); / / restore on departure

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report