Forum rules - please read before posting.

Render software cursor in camera space using UI?

@ChrisIceBox you posted in a lost topic a script for using a software cursor as a UI so it can be placed in camera space instead of Unity's standard overlay, do you still have this example? I used the script in a project, but I believe you mentioned how to set it up in AC, too. I wonder if this might be considered incorporated in the cursor menu at some point? It could definitely be useful for a pixel-precisional cursor (check ScummVM for this), as it was posted before for allowing cameras to coroutine on slower frame rates whilst the software cursor renders at full frame speed, or even for cursor effects via camera post-processing.

Comments


  • Attach it to a RawImage component and switch to Hardware cursor rendering.  The script'll set the RawImage's texture to match the hardware cursor, and reposition it to where the mouse cursor is.
  • I'm getting:
    NullReferenceException: Object reference not set to an instance of an object
    UnityUICursor.Update () (at Assets/UnityUICursor.cs:28)

    and

    NullReferenceException: Object reference not set to an instance of an object
    UnityUICursor.OnSetHardwareCursor (UnityEngine.Texture2D texture, Vector2 clickOffset) (at Assets/UnityUICursor.cs:35)
    AC.EventManager.Call_OnSetHardwareCursor (UnityEngine.Texture2D cursorTexture, Vector2 clickOffset) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:512)
    AC.PlayerCursor.SetHardwareCursor (UnityEngine.Texture2D texture2D, Vector2 clickOffset) (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:814)
    AC.PlayerCursor.DrawCursor () (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:238)
    AC.PlayerCursor.UpdateCursor () (at Assets/AdventureCreator/Scripts/Controls/PlayerCursor.cs:195)
    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:267)

    and it seems to break interactions a bit, did I miss something?
  • Those both refer to the RawImage component which should be on the same GameObject as the script.
  • edited November 2018
    Does this definitely work when the UiCursor gameobject is set to "screen space- camera"? It works with overlay (except for "empty texture" displaying a white box and not returning to the original cursor after the cutscene is over) but camera space seems to not display any cursor using this method. It appears to be for the same reason the SubtitlesUI didn't work in camera space, the positioning seems to be -5000 pixels out of view, as Unity still seems to think it's scaled for overlay. How did you fix this for menus, and is it possible to do this with this script?
  • Thanks! Do all of the parameters need manually choosing in the inspector? Also, how do I make the hardware cursor invisible using the updated script?
  • The AC cursor will be set to whatever you assign in the "Empty Texture" field.

    The Animator fields are all optional - they'll only take effect if you assign an Animator and parameter names.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.