当前位置:   article > 正文

Unity鼠标设置_unity鼠标x未设置

unity鼠标x未设置

Unity的默认鼠标可以在Playersettings里设置Default Cursor的默认鼠标样式。

在代码中的设置:

  1. public Texture2D idleTex;
  2. public Texture2D clickTex;
  3. // Use this for initialization
  4. void Start ()
  5. {
  6. Screen.showCursor = false;
  7. }
  8. void OnGUI ()
  9. {
  10. Vector3 pos = Input.mousePosition;
  11. if (Input.GetMouseButtonDown (0))
  12. {
  13. GUI.DrawTexture (new Rect (pos.x, Screen.height - pos.y, clickTex.width, clickTex.height), clickTex);
  14. }
  15. else
  16. {
  17. GUI.DrawTexture (new Rect (pos.x, Screen.height - pos.y, idleTex.width, idleTex.height), idleTex);
  18. }
  19. }

这里的Screen.showCursor需要在实际项目中才起效。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/48775
推荐阅读
相关标签
  

闽ICP备14008679号