Custom Mouse Pointer

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Changes category "C#" into "C Sharp"; removed category Javascript)
Line 1: Line 1:
[[Category: C#]]
+
[[Category: C Sharp]]
[[Category: Javascript]]
+
 
[[Category: GUI]]
 
[[Category: GUI]]
 
Author: [[User:Kiyaku|Kiyaku]]
 
Author: [[User:Kiyaku|Kiyaku]]

Revision as of 20:41, 16 April 2011

Author: Kiyaku

Description

If you want a custom image for your mouse pointer but still have it in front of the OnGUI() elements, use this little script.

Usage

Attach this script to any gameObject you want, preferable a new empty one. Assign your custom Texture to the script.

C# - mousePointer.cs

<csharp> using UnityEngine; using System.Collections;

public class mousePointer : MonoBehaviour {

   public Texture2D cursorImage;
   private int cursorWidth = 32;
   private int cursorHeight = 32;
   void Start()
   {
       Screen.showCursor = false;
   }


   void OnGUI()
   {
       GUI.DrawTexture(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, cursorWidth, cursorHeight), cursorImage);
   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox