Hi,
I have the Problem that i want to write a c# scipt to change my mouse cursor if it is over some object. So far no problem if i set teh texture manually in the inspector but now i want to change it in that way that the Texture (a png picture with alpha transparancy effect, imported as cursor texture) is loaded automatically in the script, too.
For doing this is added the line
:
void start() {
cursorTexture = (Texture2D)Resources.Load("Assets/cursors/cursorTake.png");
}
and also tried it without complete path and without the file extension. But it is never working
Does somebody have any idea what i have done wrong?
using UnityEngine;
using System.Collections;
public class cursorControl : MonoBehaviour {
public Vector2 hotSpot = Vector2.zero;
private CursorMode cursorMode = CursorMode.Auto;
private Texture2D cursorTexture;
void start() {
cursorTexture = (Texture2D)Resources.Load("Assets/cursors/cursorTake.png");
}
void OnMouseEnter() {
Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);
}
void OnMouseExit() {
Cursor.SetCursor(null, Vector2.zero, cursorMode);
}
}