Create
Script “MouseCursor” to change the texture of the mouse in C# (CSharpe) or js
(JavaScript)
For c# :
using UnityEngine;
using System.Collections;
public class MouseCursor : MonoBehaviour {
public Texture2D crosshairTexture;
public Rect position;
void Start()
{
Screen.showCursor = false;
position = Rect( ( Screen.width - crosshairTexture.width ) * 0.5f, ( Screen.height - crosshairTexture.height ) * 0.5f, crosshairTexture.width, crosshairTexture.height );
}
void OnGUI()
{
GUI.DrawTexture(position, crosshairTexture);
}
}
var crosshairTexture : Texture2D;
var position : Rect;
function Start()
{
Screen.showCursor = false;
position = Rect( ( Screen.width - crosshairTexture.width ) * 0.5, ( Screen.height - crosshairTexture.height ) * 0.5, crosshairTexture.width, crosshairTexture.height );
}
function OnGUI()
{
GUI.DrawTexture(position, crosshairTexture);
}
Aucun commentaire:
Enregistrer un commentaire