tranek / GASDocumentation

My understanding of Unreal Engine 5's GameplayAbilitySystem plugin with a simple multiplayer sample project.
MIT License
4.26k stars 789 forks source link

Load gameplay tags from .ini in a Plugin/Config folder #125

Closed EnricoPietrocola closed 9 months ago

EnricoPietrocola commented 9 months ago

How can we define gameplay tags in a .ini file contained in the config folder of a plugin? I am trying but it won't load anything, I can only get to initialize correctly if the file is contained in the main project Config folder and only if the file is called "DefaultGameplayTags.ini"

ameaninglessname commented 9 months ago

Ini file in Config/Tags folder would be scaned, you could refer to other plugins in the engine.

tranek commented 9 months ago

Here's how the CommonConversation plugin does it:

void FCommonConversationRuntimeModule::StartupModule()
{
    TSharedPtr<IPlugin> ThisPlugin = IPluginManager::Get().FindPlugin(TEXT("CommonConversation"));
    check(ThisPlugin.IsValid());

    UGameplayTagsManager::Get().AddTagIniSearchPath(ThisPlugin->GetBaseDir() / TEXT("Config") / TEXT("Tags"));
}
EnricoPietrocola commented 9 months ago

Thank you for helping me

Ini file in Config/Tags folder would be scaned, you could refer to other plugins in the engine.

From the Plugins config folder? I have checked all engine plugins and I don't see any doing that, do you happen to have one I could reference from?

Here's how the CommonConversation plugin does it: void FCommonConversationRuntimeModule::StartupModule() { TSharedPtr ThisPlugin = IPluginManager::Get().FindPlugin(TEXT("CommonConversation")); check(ThisPlugin.IsValid());

UGameplayTagsManager::Get().AddTagIniSearchPath(ThisPlugin->GetBaseDir() / TEXT("Config") / TEXT("Tags")); }

I see, so there's no way to actually do this without impllementing loading, I though that .ini files were all scanned and loaded at startup

ameaninglessname commented 9 months ago

Thank you for helping me

Sorry, my memory was corrupted, tranek is right.

After putting these code in FOneOfYourModule::StartupModule, my saying is valid:

for (const TSharedPtr<const IPlugin> ThisPlugin : IPluginManager::Get().GetEnabledPluginsWithContent())
{
    if (FString TagsIniDirectory = ThisPlugin->GetBaseDir() / TEXT("Config") / TEXT("Tags");
        FPaths::DirectoryExists(TagsIniDirectory))
    {
        SOME_LOG_FUNCTION(LogRemAutoAddTagIniSearchPath, Log,
            TEXT("TagIniSearchPath: {0} Added"), TagsIniDirectory);

        UGameplayTagsManager::Get().AddTagIniSearchPath(TagsIniDirectory);
    }
}
tranek commented 9 months ago

I see, so there's no way to actually do this without impllementing loading, I though that .ini files were all scanned and loaded at startup

If you call UGameplayTagsManager::Get().AddTagIniSearchPath() in your StartupModule(), any .ini files in that directory will be scanned and loaded from your plugin at startup.

EnricoPietrocola commented 9 months ago

Now I get it! I realized yestersday while cleaning up that for some reason my Plugin's cpp an h files were completely wrong, I didn't even have module implementation at all. After fixing that I understand what you mean, I'll implement what you suggested.

Thanks a lot!