Skip to content

Commit 340a498

Browse files
committed
Merge branch 'pr/17'
2 parents ef7be6f + 3db0859 commit 340a498

33 files changed

Lines changed: 503 additions & 322 deletions

‎README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Funny snippets for working with StaticMesh and SkeletalMesh assets: https://gith
1616

1717
More tutorials: https://github.com/20tab/UnrealEnginePython/tree/master/tutorials
1818

19+
# Project Status (IMPORTANT)
20+
21+
Currently (as april 2020) the project is on hold: between 2016 and 2018 20tab invested lot of resources in it but unfortunately epic (during 2018) decided to suddenly release its own implementation and the request made for a megagrant in 2019 by the original plugin author was rejected too.
22+
23+
As this plugin (still) has way more features than the Epic one and many contributors, **we are currently looking for new maintainers** helping us to keep it alive, checking PR and issues. If you are interested in working on it a few hours a week, drop us a line at info@20tab.com to discuss about it.
24+
25+
If you are interested in game logic scripting/modding in Unreal Engine 4 consider giving a look at the LuaMachine project (https://github.com/rdeioris/LuaMachine/).
26+
27+
The plugin should work up to unreal engine version 4.23 and there are forks/pull requests for 4.24. Since 4.25 Epic refactored the UProperty subsystem, so if you want to port the plugin to a version >= 4.25 you should make a lot of search & replace (basically renaming UProperty to FProperty and Cast to CastField should be enough)
28+
1929
# How and Why ?
2030

2131
This is a plugin embedding a whole Python VM (versions 3.x [the default and suggested one] and 2.7) In Unreal Engine 4 (both the editor and runtime).
@@ -36,7 +46,7 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole'
3646

3747
All of the exposed engine features are under the 'unreal_engine' virtual module (it is completely coded in c into the plugin, so do not expect to run 'import unreal_engine' from a standard python shell)
3848

39-
The minimal supported Unreal Engine version is 4.12, while the latest is 4.23
49+
The minimal supported Unreal Engine version is 4.12, while the latest is 4.24
4050

4151
We support official python.org releases as well as IntelPython and Anaconda distributions.
4252

‎Source/PythonAutomation/PythonAutomation.Build.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public PythonAutomation(TargetInfo Target)
1313
{
1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
17-
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1817
PrivateIncludePaths.AddRange(
1918
new string[] {
2019
"PythonConsole/Private",

‎Source/PythonConsole/PythonConsole.Build.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PythonConsole(TargetInfo Target)
1313
{
1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1717

1818
PrivateIncludePaths.AddRange(
1919
new string[] {

‎Source/PythonEditor/Private/PythonEditor.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "PythonEditorStyle.h"
88
#include "PythonProjectEditor.h"
99
#include "PythonProject.h"
10+
#include "Subsystems/AssetEditorSubsystem.h"
1011
#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h"
1112

1213
static const FName PythonEditorTabName( TEXT( "PythonEditor" ) );

‎Source/PythonEditor/Private/PythonProjectEditor.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
22

33
#include "PythonProjectEditor.h"
4+
5+
#include "Subsystems/AssetEditorSubsystem.h"
6+
7+
// #include "UnrealEd.h"
8+
49
#include "SPythonEditor.h"
510
#include "SPythonProjectEditor.h"
611
#include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h"
@@ -13,6 +18,8 @@
1318
#include "PythonProjectEditorCommands.h"
1419
#include "Runtime/Core/Public/HAL/PlatformFilemanager.h"
1520
#include "Runtime/Core/Public/Misc/MessageDialog.h"
21+
22+
1623
#define LOCTEXT_NAMESPACE "PythonEditor"
1724

1825
TWeakPtr<FPythonProjectEditor> FPythonProjectEditor::PythonEditor;
@@ -209,7 +216,9 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef<class FTabManager
209216

210217
void FPythonProjectEditor::InitPythonEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, class UPythonProject* PythonProject)
211218
{
212-
FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this);
219+
// UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
220+
// GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
221+
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
213222
PythonProjectBeingEdited = PythonProject;
214223

215224
TSharedPtr<FPythonProjectEditor> ThisPtr(SharedThis(this));

‎Source/PythonEditor/PythonEditor.Build.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PythonEditor(TargetInfo Target)
1313

1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1717

1818
PrivateIncludePaths.AddRange(
1919
new string[] {
@@ -32,11 +32,13 @@ public PythonEditor(TargetInfo Target)
3232
"UnrealEd",
3333
"EditorStyle",
3434
"PropertyEditor",
35+
"ContentBrowser",
3536
"Kismet", // for FWorkflowCentricApplication
3637
"InputCore",
3738
"DirectoryWatcher",
3839
"LevelEditor",
3940
"Projects",
41+
"Engine",
4042
"UnrealEnginePython"
4143
}
4244
);

‎Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

22
#include "UEPyFMaterialEditorUtilities.h"
3+
34
#if WITH_EDITOR
45

6+
#include "Subsystems/AssetEditorSubsystem.h"
7+
58
#include "Materials/Material.h"
69
#include "Runtime/Engine/Classes/EdGraph/EdGraph.h"
710

@@ -54,7 +57,9 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args)
5457
return PyErr_Format(PyExc_Exception, "argument is not a UMaterial");
5558
}
5659

57-
IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false);
60+
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
61+
62+
IAssetEditorInstance *Instance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(Material, false);
5863
if (!Instance)
5964
{
6065
return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial");

‎Source/UnrealEnginePython/Private/PythonDelegate.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "PythonDelegate.h"
33
#include "UEPyModule.h"
44
#include "UEPyCallable.h"
5+
#include "UObject/UEPyUPropertyBackwardsCompatibility.h"
56

67
UPythonDelegate::UPythonDelegate()
78
{
@@ -37,10 +38,10 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms)
3738
py_args = PyTuple_New(signature->NumParms);
3839
Py_ssize_t argn = 0;
3940

40-
TFieldIterator<UProperty> PArgs(signature);
41+
TFieldIterator<FProperty> PArgs(signature);
4142
for (; PArgs && argn < signature->NumParms && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs)
4243
{
43-
UProperty *prop = *PArgs;
44+
FProperty *prop = *PArgs;
4445
PyObject *arg = ue_py_convert_property(prop, (uint8 *)Parms, 0);
4546
if (!arg)
4647
{
@@ -63,7 +64,7 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms)
6364
// currently useless as events do not return a value
6465
/*
6566
if (signature_set) {
66-
UProperty *return_property = signature->GetReturnProperty();
67+
FProperty *return_property = signature->GetReturnProperty();
6768
if (return_property && signature->ReturnValueOffset != MAX_uint16) {
6869
if (!ue_py_convert_pyobject(ret, return_property, (uint8 *)Parms)) {
6970
UE_LOG(LogPython, Error, TEXT("Invalid return value type for delegate"));

‎Source/UnrealEnginePython/Private/PythonFunction.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include "PythonFunction.h"
33
#include "UEPyModule.h"
4+
#include "UObject/UEPyUPropertyBackwardsCompatibility.h"
45

56

67
void UPythonFunction::SetPyCallable(PyObject *callable)
@@ -30,7 +31,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
3031

3132
// count the number of arguments
3233
Py_ssize_t argn = (Context && !is_static) ? 1 : 0;
33-
TFieldIterator<UProperty> IArgs(function);
34+
TFieldIterator<FProperty> IArgs(function);
3435
for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) {
3536
argn++;
3637
}
@@ -56,7 +57,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
5657

5758
// is it a blueprint call ?
5859
if (*Stack.Code == EX_EndFunctionParms) {
59-
for (UProperty *prop = (UProperty *)function->Children; prop; prop = (UProperty *)prop->Next) {
60+
for (FProperty *prop = (FProperty *)function->Children; prop; prop = (FProperty *)prop->Next) {
6061
if (prop->PropertyFlags & CPF_ReturnParm)
6162
continue;
6263
if (!on_error) {
@@ -75,7 +76,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
7576
//UE_LOG(LogPython, Warning, TEXT("BLUEPRINT CALL"));
7677
frame = (uint8 *)FMemory_Alloca(function->PropertiesSize);
7778
FMemory::Memzero(frame, function->PropertiesSize);
78-
for (UProperty *prop = (UProperty *)function->Children; *Stack.Code != EX_EndFunctionParms; prop = (UProperty *)prop->Next) {
79+
for (FProperty *prop = (FProperty *)function->Children; *Stack.Code != EX_EndFunctionParms; prop = (FProperty *)prop->Next) {
7980
Stack.Step(Stack.Object, prop->ContainerPtrToValuePtr<uint8>(frame));
8081
if (prop->PropertyFlags & CPF_ReturnParm)
8182
continue;
@@ -107,7 +108,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
107108
}
108109

109110
// get return value (if required)
110-
UProperty *return_property = function->GetReturnProperty();
111+
FProperty *return_property = function->GetReturnProperty();
111112
if (return_property && function->ReturnValueOffset != MAX_uint16) {
112113
#if defined(UEPY_MEMORY_DEBUG)
113114
UE_LOG(LogPython, Warning, TEXT("FOUND RETURN VALUE"));

‎Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "UEPyFMenuBuilder.h"
2-
2+
#include "IAssetTools.h"
33
#include "Wrappers/UEPyESlateEnums.h"
44

55
static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args)
@@ -115,6 +115,9 @@ static PyObject* py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder* self,
115115
}
116116

117117
#if WITH_EDITOR
118+
119+
#include "ContentBrowserModule.h"
120+
118121
static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, PyObject* args)
119122
{
120123
PyObject* py_assets;
@@ -140,8 +143,10 @@ static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self,
140143
Py_DECREF(py_assets);
141144

142145
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
143-
bool addedSomething = AssetToolsModule.Get().GetAssetActions(u_objects, self->menu_builder, true);
144-
if (addedSomething)
146+
147+
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
148+
TArray<FContentBrowserMenuExtender_SelectedAssets>& AssetMenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders();
149+
if (AssetMenuExtenderDelegates.Num() > 0)
145150
{
146151
Py_RETURN_TRUE;
147152
}

0 commit comments

Comments
 (0)