Locate Module Resource Path

Is there away to get the module path?

I’ve modeled my module after the plugin template that provides a toolbar button. Unforunately I’m having trouble loading the image file located in the Resources directory:

TSharedRef< FSlateStyleSet > FMyStyle::Create()
{
    TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("MyStyle"));

    //Style->SetContentRoot(IPluginManager::Get().FindPlugin("MyPlugin")->GetBaseDir() / TEXT("Resources"));
    Style->SetContentRoot(TEXT("../Resources"));

    Style->Set("MyModule.MyAction", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40));

    return Style;
}

Any help is appreciated.

Thank you.

Use the Content Directory of your Plugin Instead. You can get it with

FString ContentDir = IPluginManager::Get().FindPlugin(TEXT("MyPlugin"))->GetContentDir();

Make sure you also have “CanContainContent” : true in your MyPlugin.uplugin

Besides that look into Paper2D Plugin it is easy to understand and you can see good exaples there.

Good Luck and have Fun =)

Thank you Nachtmahr. I’m using a Gameplay / Editor Module, which may be different from the plugin structure:

Oh ok I See. If its a Game Module why you dont load directly from the Game Content folder instead? Here is a Wiki entry I came across who does it in case its a Option for you?

Otherwise I´m not sure where the Ressource Dir is in a Game Module (never create a seperate Game Module, sry ^^)

That looks like a really nice tutorial Nachtmahr :slight_smile:

I’ll look that over a little later today and see if it solves my problem. It certainly looks very similar to what I’m doing, except it may not utilize resources such as images (I could be wrong just took a quick glance at it).

Thanks.