// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Modules/ModuleManager.h"
class FfurcraeaBluePrintLibModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
furcraeaBluePrintLib.cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "furcraeaBluePrintLib.h"
#define LOCTEXT_NAMESPACE "FfurcraeaBluePrintLibModule"
void FfurcraeaBluePrintLibModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FfurcraeaBluePrintLibModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FfurcraeaBluePrintLibModule, furcraeaBluePrintLib)
furcraeaBluePrintLibBPLibrary.h
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "furcraeaBluePrintLibBPLibrary.generated.h"
/*
* Function library class.
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
*
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
* Its lets you name the node using characters not allowed in C++ function names.
* CompactNodeTitle - the word(s) that appear on the node.
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
* Good example is "Print String" node which you can find also by using keyword "log".
* Category - the category your node will be under in the Blueprint drop-down menu.
*
* For more info on custom blueprint nodes visit documentation:
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
*/
UCLASS()
class UfurcraeaBluePrintLibBPLibrary : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Execute Sample function", Keywords = "furcraeaBluePrintLib sample test testing"), Category = "furcraeaBluePrintLibTesting")
static float furcraeaBluePrintLibSampleFunction(float Param);
};
furcraeaBluePrintLibBPLibrary.cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "furcraeaBluePrintLibBPLibrary.h"
#include "furcraeaBluePrintLib.h"
UfurcraeaBluePrintLibBPLibrary::UfurcraeaBluePrintLibBPLibrary(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
float UfurcraeaBluePrintLibBPLibrary::furcraeaBluePrintLibSampleFunction(float Param)
{
return -1;
}
assets = unreal.EditorUtilityLibrary.get_selected_assets()
AssetDataList = unreal.EditorUtilityLibrary.get_selected_asset_data()
for a in AssetDataList:
if a.asset_class_path.asset_name == "StaticMesh":
mesh = unreal.EditorAssetLibrary.find_asset_data(a.package_name).get_asset()
unreal.EditorStaticMeshLibrary.remove_collisions(mesh)
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "ZFunctions.generated.h"
/**
*
*/
UCLASS()
class UE542PYTHONCALLCPP1_API UZFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
//ここから追加////////
public:
UFUNCTION(BlueprintCallable)
static void CalledFromPython(FString InputString);
//ここまで追加//////
};
ZFunctions.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "ZFunctions.h"
//ここから追加////////
void UZFunctions::CalledFromPython(FString InputString) {
UE_LOG(LogTemp, Error, TEXT("%s"), *InputString);
}
//ここまで追加//////
SolutionExplorer > your Project Name (right click)>Build
実行する。(Local Windows Debagger)
Outputlogで実行する unrealのクラス一覧
import unreal
for x in sorted(dir(unreal)):
print(x)
めっちゃ重い
ZFunction が出る
クラスを使ってみる unreal.ZFunctionsのメソッド一覧
import unreal
for x in sorted(dir(unreal.ZFunctions)):
print(x)
called_from_python が出てくる。
呼んでみる
unreal.ZFunctions.called_from_python('my test string')
//.Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "ZFunctions.generated.h"
UCLASS()
class UNREALPYTHONPROJECT_API UZFunctions : public UBlueprintFunctionLibrary
{
GENERATED BODY()
public:
UFUNCTION(BlueprintCallable)
static void CalledFromPython(FString InputString);
};
ZFunctions.cpp
//.Fill out your copyright notice in the Description page of Project Settings.
#include "ZFunctions.h"
void UZFunctions::CalledFromPython(FString InputString) {
UE_LOG(LogTemp, Error, TEXT("%s"), *InputString);
}
実行する。(Local Windows Debagger)
Outputlogで実行する
import unreal
for x in sorted(dir(unreal)):
print(x)
ZFunction が出る
import unreal
for x in sorted(dir(unreal.ZFunctions)):
print(x)
called_from_python が出てくる。
呼んでみる
unreal.ZFunctions.called_from_python('my test string')
WindowsTargetRules.Compiler to VisualStudio2019. The current compiler version was detected as: 14.29.30152
Error Message
Running F:/Program Files/Epic Games/UE_5.3/Engine/Build/BatchFiles/Build.bat -projectfiles -project="F:/Download/Game/CppFuncToBluePrint/CppFuncToBluePrint4/CppFuncToBluePrint4.uproject" -game -rocket -progress
Using bundled DotNet SDK version: 6.0.302
Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -projectfiles -project="F:/Download/Game/CppFuncToBluePrint/CppFuncToBluePrint4/CppFuncToBluePrint4.uproject" -game -rocket -progress
Log file: C:\Users\abcd\AppData\Local\UnrealBuildTool\Log_GPF.txt
Generating VisualStudio project files:
Discovering modules, targets and source code for project...
Microsoft platform targets must be compiled with Visual Studio 2022 17.4 (MSVC 14.34.x) or later for the installed engine. Please update Visual Studio 2022 and ensure no configuration is forcing WindowsTargetRules.Compiler to VisualStudio2019. The current compiler version was detected as: 14.29.30152