Download

Checking Mouse Cursor solution before post as Tutorial.

Hello.

Please, could someone check if is this correct? I’m thinking on share this code, I know it works (I’m using it), but don’t know if it’s “safe”.

The ISSUE (A): On my game I have more “types” of cursor than the allowed by the engine.
Solution: Make a mouse cursor with a MIT that does allow me to switch “standard” cursor image.

The ISSUE (B): Is hard to get a reference to the Widget instance the engine does create.
The ISSUE (C): Material Parameter Collections doesn’t works with materials used on widgets.

Solution:

  • Created a “static” pointer to an UMaterialInstanceDynamic used to define the cursor appearance C++ only since there is not static UPROPERTYies.
  • Created a Getter and Setter method exposed as UFUNCTIONs to Blueprints.

Usage:

  • Did set the UUserWidget class as parent from the Cursor Widget.
  • Did set the cursor as the Widget to be used by the engine.
  • On BeginPlay the HUD does create a dummy cursorwidget instance (just internally, never added to viewport) providing access to the widget material.

Thank you