Adventure Creator Wikia
Advertisement

This script moves display of the cursor to Unity UI, allowing you to add further effects to it if necessary. It requires AC v1.63.0 or later.

To use it:

  1. In the Cursor Manager, set the Cursor rendering mode to Hardware
  2. Create a new UI Canvas in the scene, and attach a new RawImage as a child object
  3. Attach the script below to the RawImage component

UnityUICursor.cs:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using AC;

public class UnityUICursor : MonoBehaviour
{

public Texture2D emptyTexture;
private RawImage rawImage;


private void OnEnable ()
{
EventManager.OnSetHardwareCursor += OnSetHardwareCursor;
rawImage = GetComponent <RawImage>();
}


private void OnDisable ()
{
EventManager.OnSetHardwareCursor -= OnSetHardwareCursor;
}


private void Update ()
{
rawImage.rectTransform.position = Input.mousePosition;
}


private void OnSetHardwareCursor (Texture2D texture, Vector2 clickOffset)
{
Cursor.SetCursor (emptyTexture, Vector2.zero, CursorMode.Auto);
rawImage.texture = (texture != null) ? texture : emptyTexture;
}

}
Advertisement