Skip to content

Commit 0c9838c

Browse files
author
Roberto De Ioris
committed
added Run() and RunSandboxed() methods to UPythonScript
1 parent e434467 commit 0c9838c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
#include "UnrealEnginePythonPrivatePCH.h"
22

33
#include "PythonScript.h"
4+
5+
void UPythonScript::Run() {
6+
FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");
7+
PythonModule.RunFile(TCHAR_TO_UTF8(*ScriptPath));
8+
}
9+
10+
void UPythonScript::RunSandboxed() {
11+
FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");
12+
PythonModule.RunFileSandboxed(TCHAR_TO_UTF8(*ScriptPath));
13+
}

Source/UnrealEnginePython/Public/PythonScript.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ class UPythonScript : public UObject
1919
UPROPERTY(EditAnywhere, Category = "Python")
2020
TArray<FString> FunctionArgs;
2121

22-
//void Run();
23-
//void RunSandboxed();
22+
UFUNCTION()
23+
void Run();
24+
25+
UFUNCTION()
26+
void RunSandboxed();
2427

2528
};
2629

0 commit comments

Comments
 (0)