I have an Editor Widget and inside of it I created a blueprint for some button click event.
Unfortunately, when I use the “Get game state” node (or any similar), it always returns null.
I understand that it’s correct while I don’t hit Play in Editor (there’s no game state instance).
But once I do hit Play, it’s all the same when I click the button on Editor Widget - it returns null.
At the same time, regular widgets inside game window do return the game state reference.
So, making assumption that the game is playing (I hit Play button), how to get access to Game State inside Editor Widget (like it’s possible in normal Widget)?
Here’s the step-by-step video to reproduce the problem on fresh new Unreal Engine game:
Here’s the screenshot with example blueprint and effect of Play (in Editor) and button click:
Same when I cast to my custom game state that I use in the game:
It works in User Widget and fails in Editor Widget. I can replicate it on fresh new project in UE 4.22
Yet another try. I added Actor of my custom Blueprint type to the scene.
In it, I added getGameState() method exposed to blueprint from C++.
I created two very simple, identical blueprints: one for User Widget and one for Editor Widget.
They both iterate through Actors of my type, find exactly one of them (as they should) and call to getGameState().
The one from User Widget returns the correct memory address of game state:
While at the same time, the exact same blueprint from Editor Widget returns null:
Here’s the screenshot of Unreal Engine Editor (1 - button on User Widget, 2 - button on Editor Widget).
Also note: the world pointer is different for User Widget and Editor Utility Widget.
p.s. I am working on simple, single-player case.