-
1、定义设置哪些参数
UCLASS(config=Engine, globaluserconfig) class ADVMOD_API UGlobalSettings : public UObject {GENERATED_BODY()public:UGlobalSettings();const FString& GetPythonExePath() const { return PythonExePath.FilePath; }private:UPROPERTY(config, EditAnywhere, Category = "Path", meta = (DisplayName = "Python exe path"))FFilePath PythonExePath;UPROPERTY(config, EditAnywhere, Category = "Path", meta = (DisplayName = "Python64"))bool x64; };
-
2、模块启动时,注册
void FAdvModModule::StartupModule() { 项目设置 /RegisterSettings(); }void FAdvModModule::RegisterSettings() {ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");if (!SettingsModule) return;SettingsModule->RegisterSettings("Project", "Plugins", "AdvGlobalSettings", FText::FromString("Adv"), FText::FromString("Configure the Adv plugin."), GetMutableDefault<UGlobalSettings>()); }
-
卸载
void FAdvModModule::ShutdownModule() {UnregisterSettings(); }void FAdvModModule::UnregisterSettings() {ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");if (!SettingsModule) return;SettingsModule->UnregisterSettings("Project", "Plugins", "AdvGlobalSettings"); }
-
-
3、使用
GetDefault<UGlobalSettings>()->GetPythonExePath();