Skip to content

Commit bf74252

Browse files
committed
Merge branch 'release/1.0'
2 parents 0436095 + 3cc0cfe commit bf74252

File tree

9 files changed

+1463
-0
lines changed

9 files changed

+1463
-0
lines changed

.gitignore

Lines changed: 584 additions & 0 deletions
Large diffs are not rendered by default.

Config/FilterPlugin.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[FilterPlugin]
2+
/README.md

LICENSE.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

PythonBlueprintFixer.uplugin

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"FileVersion": 3,
3+
"Version": 1,
4+
"VersionName": "1.0.0",
5+
"FriendlyName": "Python Blueprint Fixer",
6+
"Description": "The plugin edits loading phase of python scripts so the blueprints will compile properly on editor startup.",
7+
"Category": "Editor",
8+
"CreatedBy": "Gradess Games",
9+
"CreatedByURL": "https://stepantrofimov.com",
10+
"DocsURL": "",
11+
"MarketplaceURL": "",
12+
"SupportURL": "https://discord.gg/zFK38y68tK",
13+
"CanContainContent": false,
14+
"IsBetaVersion": false,
15+
"IsExperimentalVersion": false,
16+
"Installed": false,
17+
"Modules": [
18+
{
19+
"Name": "PythonBlueprintFixer",
20+
"Type": "Editor",
21+
"LoadingPhase": "PostEngineInit",
22+
"WhitelistPlatforms": [
23+
"Win64"
24+
]
25+
}
26+
],
27+
"Plugins": [
28+
{
29+
"Name": "PythonScriptPlugin",
30+
"Enabled": true
31+
}
32+
]
33+
}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Python Blueprint Fixer
2+
3+
## Description
4+
Simple plugin that fixes Unreal Engine python scripts loading phase that causes blueprint compilation errors. Especially it helps if you use a lot of Editor Utility Widgets that uses python scripts and are opened on engine startup.
5+
6+
## How to install
7+
1. Download [latest release](https://github.com/Gradess2019/PythonBlueprintFixer/releases/latest) for your Unreal Engine version
8+
2. Unzip into: **\<ProjectDirectory\>/Plugins** (create Plugins directory if it doesn't exist)
9+
3. If you are using C++: Right Mouse Button on your **.uproject** file -> Generate Visual Studio project files
10+
4. Launch project
11+
5. If it's not enabled: Go to Edit -> Plugins -> "Project" category -> Editor -> Enable "Python Blueprint Fixer" and restart the editor
12+
7. Done
13+
14+
## How to use
15+
Add your python scripts to Startup Scripts in project settings [as you usually do](https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/ScriptingAndAutomation/Python/#startupscripts).
16+
The plugin will start its work automatically. No additional steps required. Enjoy!

Resources/Icon128.png

2.27 KB
Loading
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2023 Gradess Games. All Rights Reserved.
2+
3+
#include "PythonBlueprintFixer.h"
4+
#include "IPythonScriptPlugin.h"
5+
6+
#define LOCTEXT_NAMESPACE "FPythonBlueprintFixerModule"
7+
8+
void FPythonBlueprintFixerModule::StartupModule()
9+
{
10+
CopyStartupScriptsFromPlugin();
11+
RunStartupScripts();
12+
}
13+
14+
void FPythonBlueprintFixerModule::ShutdownModule()
15+
{
16+
}
17+
18+
TObjectPtr<UObject> FPythonBlueprintFixerModule::GetPythonSettings() const
19+
{
20+
const auto CDOName = TEXT("/Script/PythonScriptPlugin.Default__PythonScriptPluginSettings");
21+
return StaticFindObject(UObject::StaticClass(), nullptr, CDOName);
22+
}
23+
24+
FProperty* FPythonBlueprintFixerModule::GetStratupScriptArrayProperty(TObjectPtr<UObject> PythonSettings) const
25+
{
26+
checkf(PythonSettings, TEXT("UPythonScriptPluginSettings default object not found"));
27+
return PythonSettings->GetClass()->FindPropertyByName(TEXT("StartupScripts"));
28+
}
29+
30+
void FPythonBlueprintFixerModule::CopyStartupScriptsFromPlugin()
31+
{
32+
const auto PythonSettings = GetPythonSettings();
33+
const auto StartupScriptsField = GetStratupScriptArrayProperty(PythonSettings);
34+
checkf(StartupScriptsField, TEXT("StartupScripts field not found in PythonSettings"));
35+
36+
StartupScriptsField->GetValue_InContainer(PythonSettings, &StartupScripts);
37+
StartupScriptsField->ClearValue_InContainer(PythonSettings);
38+
39+
constexpr auto Delay = 1.f;
40+
ModuleDelayedHandle = FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateRaw(this, &FPythonBlueprintFixerModule::OnTick), Delay);
41+
}
42+
43+
void FPythonBlueprintFixerModule::SetStartupScriptsBack() const
44+
{
45+
const auto PythonSettings = GetPythonSettings();
46+
const auto StartupScriptsField = GetStratupScriptArrayProperty(PythonSettings);
47+
checkf(StartupScriptsField, TEXT("StartupScripts field not found in PythonSettings"));
48+
49+
StartupScriptsField->SetValue_InContainer(PythonSettings, &StartupScripts);
50+
}
51+
52+
void FPythonBlueprintFixerModule::RunStartupScripts() const
53+
{
54+
auto& PythonModule = FModuleManager::LoadModuleChecked<IPythonScriptPlugin>("PythonScriptPlugin");
55+
56+
for (const auto& StartupScript : StartupScripts)
57+
{
58+
PythonModule.ExecPythonCommand(*StartupScript);
59+
}
60+
}
61+
62+
bool FPythonBlueprintFixerModule::OnTick(float InDeltaTime)
63+
{
64+
ModuleDelayedHandle.Reset();
65+
66+
SetStartupScriptsBack();
67+
68+
return false;
69+
}
70+
71+
#undef LOCTEXT_NAMESPACE
72+
73+
IMPLEMENT_MODULE(FPythonBlueprintFixerModule, PythonBlueprintFixer)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2023 Gradess Games. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include "CoreMinimal.h"
6+
#include "Modules/ModuleManager.h"
7+
8+
class FPythonBlueprintFixerModule : public IModuleInterface
9+
{
10+
public:
11+
TArray<FString> StartupScripts;
12+
FTSTicker::FDelegateHandle ModuleDelayedHandle;
13+
14+
/** IModuleInterface implementation */
15+
virtual void StartupModule() override;
16+
virtual void ShutdownModule() override;
17+
18+
private:
19+
TObjectPtr<UObject> GetPythonSettings() const;
20+
FProperty* GetStratupScriptArrayProperty(TObjectPtr<UObject> PythonSettings) const;
21+
22+
void CopyStartupScriptsFromPlugin();
23+
void RunStartupScripts() const;
24+
25+
bool OnTick(float InDeltaTime);
26+
void SetStartupScriptsBack() const;
27+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2023 Gradess Games. All Rights Reserved.
2+
3+
using UnrealBuildTool;
4+
5+
public class PythonBlueprintFixer : ModuleRules
6+
{
7+
public PythonBlueprintFixer(ReadOnlyTargetRules Target) : base(Target)
8+
{
9+
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
10+
11+
PublicIncludePaths.AddRange(
12+
new string[] {
13+
// ... add public include paths required here ...
14+
}
15+
);
16+
17+
18+
PrivateIncludePaths.AddRange(
19+
new string[] {
20+
// ... add other private include paths required here ...
21+
}
22+
);
23+
24+
25+
PublicDependencyModuleNames.AddRange(
26+
new string[]
27+
{
28+
"Core",
29+
// ... add other public dependencies that you statically link with here ...
30+
}
31+
);
32+
33+
34+
PrivateDependencyModuleNames.AddRange(
35+
new string[]
36+
{
37+
"CoreUObject",
38+
"Engine",
39+
"Slate",
40+
"SlateCore",
41+
"PythonScriptPlugin",
42+
// ... add private dependencies that you statically link with here ...
43+
}
44+
);
45+
46+
47+
DynamicallyLoadedModuleNames.AddRange(
48+
new string[]
49+
{
50+
// ... add any modules that your module loads dynamically here ...
51+
}
52+
);
53+
}
54+
}

0 commit comments

Comments
 (0)