日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Unity 动态更改鼠标样式

發(fā)布時(shí)間:2024/8/1 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity 动态更改鼠标样式 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

方法參考博客:https://gameinstitute.qq.com/community/detail/118295

using System.Runtime.InteropServices;public class CursorTools {[DllImport("User32.DLL")]public static extern IntPtr LoadCursorFromFile(string fileName);[DllImport("User32.DLL")]public static extern bool SetSystemCursor(IntPtr hcur, uint id);public const uint OCR_NORMAL = 32512;[DllImport("User32.DLL")]public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);public const uint SPI_SETCURSORS = 87;public const uint SPIF_SENDWININICHANGE = 2;/// <summary>/// 把準(zhǔn)備好的.cur指針資源放在StreamingAssets/Cursors下,記得創(chuàng)建好這個(gè)文件夾/// </summary>private static string CursorPath(string fileName){return Path.Combine(Application.streamingAssetsPath, "Cursors", fileName) + ".cur";}/// <summary>/// 恢復(fù)Windows正常鼠標(biāo)指針/// </summary>public static void Reset2NormalCursor(){SystemParametersInfo(SPI_SETCURSORS, 0, IntPtr.Zero, SPIF_SENDWININICHANGE);}/// <summary>/// 設(shè)置拖拽移動(dòng)樣式的指針/// </summary>public static void SetDragCursor(){IntPtr hcur_drag = LoadCursorFromFile(CursorPath("aero_move"));SetSystemCursor(hcur_drag, OCR_NORMAL);} }

以拖拽功能為例,想拖拽的時(shí)候調(diào)用:

CursorTools.SetDragCursor();

用完記得把指針變回來(lái):

CursorTools.Reset2NormalCursor();

C:\Windows\Cursors文件夾下面有很多Windows默認(rèn)鼠標(biāo)資源。

總結(jié)

以上是生活随笔為你收集整理的Unity 动态更改鼠标样式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。