Skip to content

Commit ed01280

Browse files
author
Roberto De Ioris
committed
more robust create_blueprint()
1 parent 3441781 commit ed01280

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,16 @@ PyObject *py_unreal_engine_create_blueprint(PyObject * self, PyObject * args) {
799799
if (!outer)
800800
return PyErr_Format(PyExc_Exception, "unable to create package");
801801

802+
if (FindObject<UBlueprint>(outer, UTF8_TO_TCHAR(bp_name)) != nullptr)
803+
return PyErr_Format(PyExc_Exception, "there is already a Blueprint with this name");
804+
802805
UBlueprint *bp = FKismetEditorUtilities::CreateBlueprint(parent, outer, UTF8_TO_TCHAR(bp_name), EBlueprintType::BPTYPE_Normal, UBlueprint::StaticClass(), UBlueprintGeneratedClass::StaticClass());
803-
if (bp) {
804-
FAssetRegistryModule::AssetCreated(bp);
805-
outer->MarkPackageDirty();
806-
}
806+
if (!bp)
807+
return PyErr_Format(PyExc_Exception, "unable to create Blueprint");
808+
809+
FAssetRegistryModule::AssetCreated(bp);
810+
outer->MarkPackageDirty();
811+
807812

808813
ue_PyUObject *ret = ue_get_python_wrapper(bp);
809814
if (!ret)

0 commit comments

Comments
 (0)