Hi
To control image and color of my cursor I need to get access to cursor widget which was created in initialization process (my cursor widget seted as default in project settings). How can I do that?
Hi
To control image and color of my cursor I need to get access to cursor widget which was created in initialization process (my cursor widget seted as default in project settings). How can I do that?
I’ve experienced that cursor widget BP code does not run in standalone / commandline versions of the game.
So before you go full tilt on your planned objectives for your project, I recommend you verify that you can get any BP code to work for a cursor widget when game is run in Standalone/ commandline only / packaged game.
This should save you a lot of time and effort if you get the same result I’ve been getting since cursor widget was released.
I made an answerhub about this issue here:
Regarding your actual question, You can set up BP code in the cursor widget that sends a ref to itself over to your PC/game instance and is stored in a C++ BP-exposed variable.
But as I've stated, I can't get BP code for cursors to work in packaged/standalone/commandline versions of the game.
Good luck!
Rama
Cursor BP Code
Dear Alanir,
I’ve experienced that cursor widget BP code does not run in standalone / commandline versions of the game.
So before you go full tilt on your planned objectives for your project, I recommend you verify that you can get any BP code to work for a cursor widget when game is run in Standalone/ commandline only / packaged game.
This should save you a lot of time and effort if you get the same result I’ve been getting since cursor widget was released.
I made an answerhub about this issue here:
Regarding your actual question, You can set up BP code in the cursor widget that sends a ref to itself ( "Get Reference To Self" ) over to your PC/game instance and is stored in a C++ BP-exposed variable.
But as I've stated, I can't get BP code for cursors to work in packaged/standalone/commandline versions of the game (true as of 4.8).
If anyone can verify cursor BP code, including things like delays and timers, working in a packaged/commandline version of the game I'd be very excited to know about it!
Good luck!
:)
Rama
Hi Rama,
Thank you for the answer. But I’m seeking some native solution without middle-saving actions. I hope it exists.
I have just built project through shipping and I got my cursor’s blueprint emplementable events works fine.
Oh that’s great to hear!
**Delay Nodes Not Working in Commandline/Standalone
**
The issue I am having still is not resolved in 4.8.3, you can do a quick test by adding a delay and then a printstring to Construct event in the cursor widget, of say 2-3 seconds. If you run the game in PIE (in viewport) then the delay fires off and the message gets printed.
But if I run the game in standalone, the print string never gets fired.
I am mentioning this in the hopes it saves you and everyone some debugging time if you have issues using cursor blueprint code in standalone/commandline versions of the game.
**
Looping Timers Do Work!**
I just tested and looping timers DO work in Standalone/commandline, it is only delay nodes that do not appear to be working.
Enjoy!
Rama
Accessing OS Cursor Widgets
Dear Alanir,
The cursor widgets are stored in a private TMap in GameViewportClient
private:
/** Map of Cursor Widgets*/
TMap<EMouseCursor::Type, TSharedRef<SWidget>> CursorWidgets;
The TMap is filled by AddCursor(), which is also private.
**TakeWidget**
Please note AddCursor extracts the inner SWidget of the BP-friendly UUserWidget:
```
CursorWidgets.Add(Cursor, UserWidget->**TakeWidget()**);
```
Accessing TMap
The only way to access the TMap is a thankfully virtual function:
virtual TOptional<TSharedRef<SWidget>> MapCursor(FViewport* Viewport, const FCursorReply& CursorReply) override;
CursorReply is used as follows in the .cpp
CursorWidgets.Find(CursorReply.GetCursorType());
**Solution**
You could construct your own CursorReply to obtain a SharedRef to the SWidget of your choosing.
The issue at this point is you have the SWidget not the UUserWidget and you can't override AddCursor to modify any part of this process.
Enjoy!
:)
Rama
Thanks, Rama!