Skip to content

Building4.25 #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f8e0a91
FRotator arguments order should be `pitch` `yaw` `roll` instead of `r…
F0x06 May 3, 2019
bfdea2a
Merge pull request #718 from F0x06/frotator-args-fix
Jun 15, 2020
3ff694e
Added define for FRotator argument order if really want original Unre…
Jun 15, 2020
7114954
Updated to Unreal Engine 4.24.2
SaxonRah Feb 16, 2020
eb84e8c
Update README.md
SaxonRah Feb 16, 2020
607132e
Patched up differences from following merge into my master.
May 6, 2020
d0b0a72
Remove hosts-per-state.py from Source - does not seem appropriate place.
Jun 25, 2020
fca0597
Removed the IAssetTools.h - it failed to build with 4.25 and commente…
Jun 28, 2020
e3ebc3a
Wrapped some 4.24 updates with appropriate ENGINE_MINOR_VERSION so st…
Jun 28, 2020
ed3499c
More non-FProperty updates from Support4.25 pull request patched in.
Jun 28, 2020
5c96b51
Non-FProperty updates I needed to build on 4.25.
Jun 28, 2020
d957ca0
Additional function wraps added while debugging blueprint node creati…
Jun 28, 2020
e23c956
Added keyword arguments for Outer and Name for UObject instance creat…
Jun 28, 2020
f52a2c1
Missed non-FProperty update from Support4.25 pull request patched in.
Jun 28, 2020
350998c
Major update for 4.25 so can load system python shared library extens…
Jul 4, 2020
b76e101
More wraps of 4.24 updates with appropriate ENGINE_MINOR_VERSION so s…
Jul 4, 2020
4a7a3f4
Updated to use FProperty/FFieldClass instead of UProperty.
Jun 29, 2020
98e31d1
Added debug prints under define EXTRA_UE_LOG control.
Jun 29, 2020
7f9b917
Added python3.8 for Linux as that is default for Ubuntu 20.04.
Jun 29, 2020
21b4ddc
Fixup for building on Ubuntu 20.04.
Jun 29, 2020
2ccfe75
Changed to original order by default for FRotator arguments so doesnt…
Jun 30, 2020
7a21ace
Added debug prints for property conversion from or to python.
Jul 4, 2020
482355c
Revert "Added debug prints for property conversion from or to python."
Jul 4, 2020
c0a0089
More updates to fix 4.25 deprecations.
Jul 5, 2020
584f78f
Possible fixup for PlayInEditor 4.25 changes.
Jul 5, 2020
1ce237e
Fix the blueprint variable unit test.
jonlm May 1, 2019
c686eb1
Added new versions of some examples to work in 4.25.
Jul 5, 2020
9da24f4
Correct debug code - added EXTRA_DEBUG_CODE ifdef wrap.
Jul 17, 2020
06ef4b3
Added pragmas to convert -Wshadow from errors to warnings for Fbx mod…
Jul 17, 2020
d04c3af
Wrapped more editor only functions with WITH_EDITOR to allow package …
Jul 20, 2020
1a8cd3e
Created new type check functions for FProperty and updated py_ue_get_…
Jul 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole'

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)

The minimal supported Unreal Engine version is 4.12, while the latest is 4.23
The minimal supported Unreal Engine version is 4.12, while the latest is 4.24

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

Expand Down
3 changes: 1 addition & 2 deletions Source/PythonAutomation/PythonAutomation.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public PythonAutomation(TargetInfo Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);

bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
PrivateIncludePaths.AddRange(
new string[] {
"PythonConsole/Private",
Expand Down
2 changes: 1 addition & 1 deletion Source/PythonConsole/PythonConsole.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public PythonConsole(TargetInfo Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);

PrivateIncludePaths.AddRange(
new string[] {
Expand Down
5 changes: 4 additions & 1 deletion Source/PythonEditor/Private/PythonEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "PythonEditorStyle.h"
#include "PythonProjectEditor.h"
#include "PythonProject.h"
#if ENGINE_MINOR_VERSION >= 24
#include "Subsystems/AssetEditorSubsystem.h"
#endif
#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h"

static const FName PythonEditorTabName( TEXT( "PythonEditor" ) );
Expand Down Expand Up @@ -90,4 +93,4 @@ class FPythonEditor : public IModuleInterface

IMPLEMENT_MODULE( FPythonEditor, PythonEditor )

#undef LOCTEXT_NAMESPACE
#undef LOCTEXT_NAMESPACE
15 changes: 15 additions & 0 deletions Source/PythonEditor/Private/PythonProjectEditor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "PythonProjectEditor.h"

#if ENGINE_MINOR_VERSION >= 24
#include "Subsystems/AssetEditorSubsystem.h"

// #include "UnrealEd.h"
#endif

#include "SPythonEditor.h"
#include "SPythonProjectEditor.h"
#include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h"
Expand All @@ -13,6 +20,8 @@
#include "PythonProjectEditorCommands.h"
#include "Runtime/Core/Public/HAL/PlatformFilemanager.h"
#include "Runtime/Core/Public/Misc/MessageDialog.h"


#define LOCTEXT_NAMESPACE "PythonEditor"

TWeakPtr<FPythonProjectEditor> FPythonProjectEditor::PythonEditor;
Expand Down Expand Up @@ -209,7 +218,13 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef<class FTabManager

void FPythonProjectEditor::InitPythonEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, class UPythonProject* PythonProject)
{
#if ENGINE_MINOR_VERSION >= 24
// UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
// GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
#else
FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this);
#endif
PythonProjectBeingEdited = PythonProject;

TSharedPtr<FPythonProjectEditor> ThisPtr(SharedThis(this));
Expand Down
14 changes: 14 additions & 0 deletions Source/PythonEditor/Private/PythonProjectEditorCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ FPythonProjectEditorCommands::FPythonProjectEditorCommands()

void FPythonProjectEditorCommands::RegisterCommands()
{
#if ENGINE_MINOR_VERSION >= 25
UI_COMMAND(New, "New", "New Python Script.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control, EKeys::N));
UI_COMMAND(NewDirectory, "New Directory", "New Directory.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control | EModifierKey::Shift, EKeys::N));
UI_COMMAND(Delete, "Delete", "Delete Python Script.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control, EKeys::D));

UI_COMMAND(Save, "Save", "Save the currently active document.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control, EKeys::S));
UI_COMMAND(SaveAll, "Save All", "Save all open documents.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control | EModifierKey::Shift, EKeys::S));
UI_COMMAND(Execute, "Execute", "Execute Current Python File.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control, EKeys::Enter));
#if PLATFORM_MAC
UI_COMMAND(ExecuteInMainThread, "Execute In Main Thread", "Execute Current Python File in the Main Thread.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control | EModifierKey::Shift, EKeys::Enter));
#endif
UI_COMMAND(PEP8ize, "PEP8-ize", "Enforce PEP8 to the current code.", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control | EModifierKey::Shift, EKeys::P));
#else
UI_COMMAND(New, "New", "New Python Script.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control, EKeys::N));
UI_COMMAND(NewDirectory, "New Directory", "New Directory.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::N));
UI_COMMAND(Delete, "Delete", "Delete Python Script.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control, EKeys::D));
Expand All @@ -25,6 +38,7 @@ void FPythonProjectEditorCommands::RegisterCommands()
UI_COMMAND(ExecuteInMainThread, "Execute In Main Thread", "Execute Current Python File in the Main Thread.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::Enter));
#endif
UI_COMMAND(PEP8ize, "PEP8-ize", "Enforce PEP8 to the current code.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::P));
#endif

}

Expand Down
4 changes: 3 additions & 1 deletion Source/PythonEditor/PythonEditor.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public PythonEditor(TargetInfo Target)

PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);

PrivateIncludePaths.AddRange(
new string[] {
Expand All @@ -32,11 +32,13 @@ public PythonEditor(TargetInfo Target)
"UnrealEd",
"EditorStyle",
"PropertyEditor",
"ContentBrowser",
"Kismet", // for FWorkflowCentricApplication
"InputCore",
"DirectoryWatcher",
"LevelEditor",
"Projects",
"Engine",
"UnrealEnginePython"
}
);
Expand Down
34 changes: 34 additions & 0 deletions Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args)
{
return PyErr_Format(PyExc_Exception, "argument is not a child of UEdGraphNode");
}
EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node: Casting to class %s"), *u_class->GetName());
node = NewObject<UEdGraphNode>(graph, u_class);
node->PostLoad();
}
Expand All @@ -328,6 +329,7 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args)

node->Rename(*node->GetName(), graph);
}
EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node: renaming node"));
}

if (!node)
Expand All @@ -337,8 +339,10 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args)
node->CreateNewGuid();
node->PostPlacedNewNode();
node->SetFlags(RF_Transactional);
EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node: allocate pins current pins num %d"), node->Pins.Num());
if (node->Pins.Num() == 0)
{
EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node: allocating pins"));
node->AllocateDefaultPins();
}
node->NodePosX = x;
Expand Down Expand Up @@ -527,6 +531,8 @@ PyObject *py_ue_graph_add_node_dynamic_cast(ue_PyUObject * self, PyObject * args
if(!u_class)
return PyErr_Format(PyExc_Exception, "argument is not a UClass");

EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node_dynamic_cast: Casting to class %s %p"), *u_class->GetName(), (void *)u_class);

UK2Node_DynamicCast *node = NewObject<UK2Node_DynamicCast>(graph);
node->TargetType = u_class;
#if ENGINE_MINOR_VERSION > 15
Expand Down Expand Up @@ -555,6 +561,8 @@ PyObject *py_ue_graph_add_node_dynamic_cast(ue_PyUObject * self, PyObject * args
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp);
}

EXTRA_UE_LOG(LogPython, Warning, TEXT("add_node_dynamic_cast: targettype is %p"), (void *)(node->TargetType));

Py_RETURN_UOBJECT(node);
}

Expand Down Expand Up @@ -654,6 +662,32 @@ PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args)
return py_ue_new_edgraphpin(pin);
}

PyObject *py_ue_node_set_purity(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);

PyObject *py_bool = nullptr;
if (!PyArg_ParseTuple(args, "O:set_purity", &py_bool))
{
return nullptr;
}

UK2Node_DynamicCast *node = ue_py_check_type<UK2Node_DynamicCast>(self);
if (!node)
return PyErr_Format(PyExc_Exception, "uobject is not a K2Node_DynamicCast");

if (PyObject_IsTrue(py_bool))
{
node->SetPurity(true);
}
else
{
node->SetPurity(false);
}

Py_RETURN_NONE;
}

PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject * self, PyObject * args)
{

Expand Down
2 changes: 2 additions & 0 deletions Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ PyObject *py_ue_node_create_pin(ue_PyUObject *, PyObject *);
PyObject *py_ue_node_pin_type_changed(ue_PyUObject *, PyObject *);
PyObject *py_ue_node_pin_default_value_changed(ue_PyUObject *, PyObject *);

PyObject *py_ue_node_set_purity(ue_PyUObject *, PyObject *);

PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject *, PyObject *);

PyObject *py_ue_node_get_title(ue_PyUObject *, PyObject *);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,15 @@ static int py_ue_edgraphpin_set_sub_category(ue_PyEdGraphPin *self, PyObject *va
return -1;
}

static PyObject *py_ue_edgraphpin_get_direction(ue_PyEdGraphPin *self, void *closure)
{
uint8 direction = self->pin->Direction;
return PyLong_FromLong((long)direction);
}

static PyGetSetDef ue_PyEdGraphPin_getseters[] = {
{ (char*)"name", (getter)py_ue_edgraphpin_get_name, NULL, (char *)"", NULL },
{ (char*)"direction", (getter)py_ue_edgraphpin_get_direction, NULL, (char *)"", NULL },
{ (char*)"category", (getter)py_ue_edgraphpin_get_category, (setter)py_ue_edgraphpin_set_category, (char *)"", NULL },
{ (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, (setter)py_ue_edgraphpin_set_sub_category, (char *)"", NULL },
{ (char*)"default_value", (getter)py_ue_edgraphpin_get_default_value, (setter)py_ue_edgraphpin_set_default_value, (char *)"", NULL },
Expand Down
1 change: 1 addition & 0 deletions Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#if PLATFORM_LINUX
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wnull-dereference"
#pragma clang diagnostic warning "-Wshadow"
#endif
#endif

Expand Down
1 change: 1 addition & 0 deletions Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#if PLATFORM_LINUX
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wnull-dereference"
#pragma clang diagnostic warning "-Wshadow"
#endif
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

#include "UEPyFMaterialEditorUtilities.h"

#if WITH_EDITOR

#if ENGINE_MINOR_VERSION >= 24
#include "Subsystems/AssetEditorSubsystem.h"
#endif

#include "Materials/Material.h"
#include "Runtime/Engine/Classes/EdGraph/EdGraph.h"

Expand Down Expand Up @@ -54,7 +59,13 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args)
return PyErr_Format(PyExc_Exception, "argument is not a UMaterial");
}

#if ENGINE_MINOR_VERSION >= 24
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();

IAssetEditorInstance *Instance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(Material, false);
#else
IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false);
#endif
if (!Instance)
{
return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial");
Expand Down Expand Up @@ -128,4 +139,4 @@ void ue_python_init_fmaterial_editor_utilities(PyObject *ue_module)
PyModule_AddObject(ue_module, "FMaterialEditorUtilities", (PyObject *)&ue_PyFMaterialEditorUtilitiesType);
}

#endif
#endif
12 changes: 12 additions & 0 deletions Source/UnrealEnginePython/Private/PythonDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms)
py_args = PyTuple_New(signature->NumParms);
Py_ssize_t argn = 0;

#if ENGINE_MINOR_VERSION >= 25
TFieldIterator<FProperty> PArgs(signature);
#else
TFieldIterator<UProperty> PArgs(signature);
#endif
for (; PArgs && argn < signature->NumParms && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs)
{
#if ENGINE_MINOR_VERSION >= 25
FProperty *prop = *PArgs;
#else
UProperty *prop = *PArgs;
#endif
PyObject *arg = ue_py_convert_property(prop, (uint8 *)Parms, 0);
if (!arg)
{
Expand All @@ -63,7 +71,11 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms)
// currently useless as events do not return a value
/*
if (signature_set) {
#if ENGINE_MINOR_VERSION >= 25
FProperty *return_property = signature->GetReturnProperty();
#else
UProperty *return_property = signature->GetReturnProperty();
#endif
if (return_property && signature->ReturnValueOffset != MAX_uint16) {
if (!ue_py_convert_pyobject(ret, return_property, (uint8 *)Parms)) {
UE_LOG(LogPython, Error, TEXT("Invalid return value type for delegate"));
Expand Down
16 changes: 16 additions & 0 deletions Source/UnrealEnginePython/Private/PythonFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)

// count the number of arguments
Py_ssize_t argn = (Context && !is_static) ? 1 : 0;
#if ENGINE_MINOR_VERSION >= 25
TFieldIterator<FProperty> IArgs(function);
#else
TFieldIterator<UProperty> IArgs(function);
#endif
for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) {
argn++;
}
Expand All @@ -56,7 +60,11 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)

// is it a blueprint call ?
if (*Stack.Code == EX_EndFunctionParms) {
#if ENGINE_MINOR_VERSION >= 25
for (FProperty *prop = (FProperty *)function->ChildProperties; prop; prop = (FProperty *)prop->Next) {
#else
for (UProperty *prop = (UProperty *)function->Children; prop; prop = (UProperty *)prop->Next) {
#endif
if (prop->PropertyFlags & CPF_ReturnParm)
continue;
if (!on_error) {
Expand All @@ -75,7 +83,11 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
//UE_LOG(LogPython, Warning, TEXT("BLUEPRINT CALL"));
frame = (uint8 *)FMemory_Alloca(function->PropertiesSize);
FMemory::Memzero(frame, function->PropertiesSize);
#if ENGINE_MINOR_VERSION >= 25
for (FProperty *prop = (FProperty *)function->ChildProperties; *Stack.Code != EX_EndFunctionParms; prop = (FProperty *)prop->Next) {
#else
for (UProperty *prop = (UProperty *)function->Children; *Stack.Code != EX_EndFunctionParms; prop = (UProperty *)prop->Next) {
#endif
Stack.Step(Stack.Object, prop->ContainerPtrToValuePtr<uint8>(frame));
if (prop->PropertyFlags & CPF_ReturnParm)
continue;
Expand Down Expand Up @@ -107,7 +119,11 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
}

// get return value (if required)
#if ENGINE_MINOR_VERSION >= 25
FProperty *return_property = function->GetReturnProperty();
#else
UProperty *return_property = function->GetReturnProperty();
#endif
if (return_property && function->ReturnValueOffset != MAX_uint16) {
#if defined(UEPY_MEMORY_DEBUG)
UE_LOG(LogPython, Warning, TEXT("FOUND RETURN VALUE"));
Expand Down
11 changes: 8 additions & 3 deletions Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "UEPyFMenuBuilder.h"

//#include "IAssetTools.h"
#include "Wrappers/UEPyESlateEnums.h"

static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args)
Expand Down Expand Up @@ -115,6 +115,9 @@ static PyObject* py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder* self,
}

#if WITH_EDITOR

#include "ContentBrowserModule.h"

static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, PyObject* args)
{
PyObject* py_assets;
Expand All @@ -140,8 +143,10 @@ static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self,
Py_DECREF(py_assets);

FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
bool addedSomething = AssetToolsModule.Get().GetAssetActions(u_objects, self->menu_builder, true);
if (addedSomething)

FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
TArray<FContentBrowserMenuExtender_SelectedAssets>& AssetMenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders();
if (AssetMenuExtenderDelegates.Num() > 0)
{
Py_RETURN_TRUE;
}
Expand Down
Loading