I would like to make custom visualizers and i want them to be useable through a plugin.
Something similar to this: https://www.youtube.com/watch?v=fhHdqz58rxQ&t=575s
It works if you edit BaseEngine.ini, or DefaultEngine.ini, but I don’t understand how to edit the ini files in a plugin
Hi, thought it was ui question but as far as I see from the tutorial, puts the mateerial description into BaseEngine.ini file with path description and it appears.
If youu want to do that from a plugin, you can write to ini file with ease when plugin module is loaded, simply with following functions.
.h
UENUM(BlueprintType)
enum class EMGIniConfigType : uint8
{
ESaveGameIni UMETA(DisplayName = "Save Game"),
EGameIni UMETA(DisplayName = "Game"),
EGameUserIni UMETA(DisplayName = "GameUser"),
EEngineIni UMETA(DisplayName = "Engine"),
EInputIni UMETA(DisplayName = "Input"),
};
UFUNCTION(BlueprintCallable, Category= "Custom Buffer Visualizations")
FString ReadIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName);
UFUNCTION(BlueprintCallable, Category= "Custom Buffer Visualizations")
void WriteIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName, const FString Value);
.cpp
TArray<FString> UYourPlugin::ReadIniSection(EMGIniConfigType IniType, const FString SectionName)
{
TArray<FString> SectionArray;
FString Config = GetConfigIni(IniType);
GConfig->GetSection(*SectionName, SectionArray, Config);
return SectionArray;
}
void UYourPlugin::WriteIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName, const FString Value)
{
GConfig->SetString(*SectionName, *PropertyName, *Value, GetConfigIni(IniType));
}
simply you can choose default .ini files with by declaring them as string values too, since GetString() and SetString() inputs are simply text, I just made them as enum so its easier to use for me.
I’m not too familiar with cpp, where could i find out more about this?
Or where would I put these?
Hi there,
To make a plugin c++ is required. You need to setup a development environment for Visual Studio and make plugin
However that post proceess effect doesn’t have to be a plugin if you are not selling it or building plugin based game code. You can just add to post process volume and it works or you can add by hand like tutorial says.
I’ll check those out thnx.
i know you can, but I want it to be reuseable easily in other projects.
I gathered i should go into Plugin::Startup Module()
and add to the DefaultEngine.ini file [Engine.BufferVisualizationMaterials] section
Not 100% sure what your script does.
Like why make read and write blueprint callable
Yes exactly, you can do this in the startup module, write function and it would write into .ini file.
Not necessaryly you have to make it blueprint callable, you can just write a UFunction and it will work.
However if you keep it, when a user enables this plugin, those functions become available in blueprints too.
So if you make something that you need to write to ini file from blueprints now you can.
I made it work Like this:
void FBufferTestModule::StartupModule()
{
FString section = TEXT("[Engine.BufferVisualizationMaterials]");
FString mat = TEXT("MyCustomPass=(Material=\"/BufferTest/BufferVisualization/PP_UnlitFresnel.PP_UnlitFresnel\", Name=LOCTEXT(\"UniltFresnel\", \"Unlit Fresnel\"))");
FString ConfigFilePath = FPaths::Combine(FPaths::ProjectConfigDir(), TEXT("DefaultEngine.ini"));
FString FileContents;
FFileHelper::LoadFileToString(FileContents, *ConfigFilePath);
if (!FileContents.Contains(section))
{
FileContents.Append(FString::Printf(TEXT("\n%s\n%s\n"), *section, *mat));
}
FFileHelper::SaveStringToFile(FileContents, *ConfigFilePath);
}
It does write to the file, but you need to restart twice before it actually appears in game.
For some reason using Set Strings and what not simply didn’t do anything
is there some way to run this when unreal restarts after enabling the plugin?
Can you try editing you yourplugin.uplugin and inside the module description
Can you edit LoadingPhase as “EarliestPossible”
"DocsURL": "",
"MarketplaceURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": true,
"Modules": [
{
"Name": "YourPlugin",
"Type": "Runtime",
"LoadingPhase": "EarliestPossible"
}
]
}
I am hoping the it would initilize before engine modules are loaded
I had it at earliest possible, sadly that still seems to be post config initiation…
Since this is for personal use mostly I will probably just include a readme or bat file that will add required lines and not touch Modules.
that could work, if its personal use especially.
You can additionally write a custom plugin.ini and declare that to engine.ini file.
That was my original Idea, But I couldn’t get it to work, and didn’t find examples of plugins that add a property like buffer visualization.
If i can make just a plugin config that would be ideal