using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mouseScript : MonoBehaviour {
public Texture2D cursorTexture;
public CursorMode cursorMode = CursorMode.Auto;
public Vector2 hotSpot = Vector2.zero;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseEnter()
{
Debug.Log("texture mouse " + cursorTexture + " cusor visiblity" + Cursor.visible);
Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);
}
void OnMouseExit()
{
Cursor.SetCursor(null, Vector2.zero, cursorMode);
}
}
I changed the mouse image properties:
- texture type - cursor
- read/write - enable html5 - override for webgl
- max size - 32
- format - RGB
- compressed - DXT1
I used this coding to change the mouse cursor. In unity editor it was working correctly, when I export to html5 mouse, cursor is not changing.
When I debug the scene in browser it displays an error like this:
Error loading this URL: Could not load the source for blob:http://localhost:56077/f3a83177-83ac-4798-81fe-1b07da4548c2. [Exception... "Failed to open input source 'file:////localhost:56077/f3a83177-83ac-4798-81fe-1b07da4548c2'" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/DevToolsUtils.js :: mainThreadFetch :: line 518" data: yes] Stack: mainThreadFetch@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/DevToolsUtils.js:518:5 _getSourceText/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/server/actors/source.js:393:27 process@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:922:23 walkerLoop@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:806:7 scheduleWalkerLoop/<@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:742:11 Line: 518, column: 0