Accessing c++ class from (widget) blueprint

Hello,

You would have to access the game instance and cast the type to your derived class:

MyUplatformGameInstance* GI = Cast<MyUplatformGameInstance>(GetWorld()->GetGameInstance());
if (GI != NULL)
{
    // Access your custom game instance members here
}

~ Dennis

Hi,

I have an UplatformGameInstance derived class. I would like to access that class from a WebBrowser widget. There are some properties in the MyUplatformGameInstance class I would like to check when instantiating the widget.

Problem is (beside me being UE newbie) that I can not find any good advice on how to access other class instances even from blueprints in general, or from WebBrowser widget in specific.

To further complicate things, it seems that UplatformGameInstance does not have any static singleton instance reference available.

So, there are couple of ways how to go forward (like deriving a MyWebBrowser, and adding a static singleton ref to the MyPlatformGameInstance), but those seem so clumsy that I suspect there are some standard UE ways to solve this?

It seems that I can use the GetGameInstance directly in the widget blueprint graph too, and cast the result into MyPlatformGameInstance, so that will solve the other problem also.

Thanks a lot!

I joyed prematurely. It seems that the BP getgameinstance returns something else than the UPlatformGameInstance. At least the casting fails.

Have you set the correct game instance class in the game mode?

Good point, it may have changed for some reason. Will check that when this bloody module rebuild completes.

Yes, that was the problem. Thanks a lot again.