// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class Projects_CustomNode : ModuleRules
{
public Projects_CustomNode(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore","RenderCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FProjects_CustomNodeModule : public FDefaultGameModuleImpl
{
public:
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
# 1 BuildManifest-Windows.txt to Auto Coding
# 1-1 Open Dir \Windows\PatchingDemo\Content\Paks
import os
dir_path = "./Windows/PatchingDemo/Content/Paks/"
files = os.listdir(dir_path)
#print(files)
txtData=""
#minus global Line -2
filelength=len(files)-2
#txtData=txtData+" $NUM_ENTRIES = 9"+"\r\n"
txtData=txtData+"$NUM_ENTRIES = "+str(filelength)+"\r"
txtData=txtData+"$BUILD_ID = PatchingDemoKey"+"\r"
for filename in files:
globalFindNum=filename.find('global')
print("globalFindNum= "+str(globalFindNum))
if(globalFindNum==0):
pass
else:
endNum=filename.find('-')
filenum=filename[8:endNum]
fileSize=os.path.getsize(dir_path+filename)
windowsPath="/Windows/"+filename
#print("filename= "+filename+" fileSize= "+str(fileSize))
tab="\t"
print(tab+filename+tab+str(fileSize)+tab+"ver01"+tab+filenum+tab+windowsPath)
txtData=txtData+filename+tab+str(fileSize)+tab+"ver001"+tab+filenum+tab+windowsPath+"\r"
filePath="./BuildManifest-Windows.txt"
f = open(filePath, 'w', encoding='UTF-8')
f.write(txtData)
f.close()
# 2 copy
起動用バッチファイル
@echo off
set cwdirpath=%~dp0
set pythonpath=D:\Sandbox\python\python-3.12.7\
set codepath=%cwdirpath%\
set pyfile=PatchingDemoKeyAuto_python.py
%pythonpath%python.exe %codepath%%pyfile%
::pause
cmd /k
ブランクなC++プロジェクトにC++フォルダがない状態で、C++ クラスを作る方法 「Tools」プルダウンメニューから「New C++ Class…」を選択します。 ここで新しいクラスを作成できます。
GameInstance
「PatchingDemoGameInstance」を作成
PatchingDemoGameInstance.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "PatchingDemoGameInstance.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPatchCompleteDelegate, bool, Succeeded);
/**
*
*/
UCLASS()
//class UPatchingDemoGameInstance : public UGameInstance
class PATCHINGDEMO_API UPatchingDemoGameInstance :public UGameInstance
{
GENERATED_BODY()
public:
// Overrides
virtual void Init() override;
virtual void Shutdown() override;
UFUNCTION(BlueprintPure, Category = "Patching|Stats")
void GetLoadingProgress(int32& BytesDownloaded, int32& TotalBytesToDownload, float& DownloadPercent, int32& ChunksMounted, int32& TotalChunksToMount, float& MountPercent) const; // Delegates
// Fired when the patching process succeeds or fails
UPROPERTY(BlueprintAssignable, Category = "Patching");
FPatchCompleteDelegate OnPatchComplete;
// Starts the game patching process.Returns false if the patching manifest is not up to date.*/
UFUNCTION(BlueprintCallable, Category = "Patching")
bool PatchGame();
protected:
//Tracks if our local manifest file is up to date with the one hosted on our website
bool bIsDownloadManifestUpToDate;
//Called when the chunk download process finishes
void OnManifestUpdateComplete(bool bSuccess);
// List of Chunk IDs to try and download
UPROPERTY(EditDefaultsOnly, Category = "Patching")
TArray<int32> ChunkDownloadList;
// Called when the chunk download process finishes
void OnDownloadComplete(bool bSuccess);
// Called whenever ChunkDownloader's loading mode is finished
void OnLoadingModeComplete(bool bSuccess);
// Called when ChunkDownloader finishes mounting chunks
void OnMountComplete(bool bSuccess);
};
PatchingDemoGameInstance.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "PatchingDemoGameInstance.h"
#include "ChunkDownloader.h"
#include "Misc/CoreDelegates.h"
#include "AssetRegistry/AssetRegistryModule.h"
void UPatchingDemoGameInstance::Init()
{
Super::Init();
const FString DeploymentName = "PatchingDemoLive";
const FString ContentBuildId = "PatchingDemoKey";
// initialize the chunk downloader with chosen platform
TSharedRef<FChunkDownloader> Downloader = FChunkDownloader::GetOrCreate();
Downloader->Initialize("Windows", 8);
// load the cached build ID
Downloader->LoadCachedBuild(DeploymentName);
// update the build manifest file
TFunction<void(bool bSuccess)> UpdateCompleteCallback = [&](bool bSuccess) {bIsDownloadManifestUpToDate = true; };
Downloader->UpdateBuild(DeploymentName, ContentBuildId, UpdateCompleteCallback);
}
void UPatchingDemoGameInstance::Shutdown()
{
Super::Shutdown();
// Shut down ChunkDownloader
FChunkDownloader::Shutdown();
}
void UPatchingDemoGameInstance::OnManifestUpdateComplete(bool bSuccess)
{
bIsDownloadManifestUpToDate = bSuccess;
}
void UPatchingDemoGameInstance::GetLoadingProgress(int32& BytesDownloaded, int32& TotalBytesToDownload, float& DownloadPercent, int32& ChunksMounted, int32& TotalChunksToMount, float& MountPercent) const
{
//Get a reference to ChunkDownloader
TSharedRef<FChunkDownloader> Downloader = FChunkDownloader::GetChecked();
//Get the loading stats struct
FChunkDownloader::FStats LoadingStats = Downloader->GetLoadingStats();
//Get the bytes downloaded and bytes to download
BytesDownloaded = LoadingStats.BytesDownloaded;
TotalBytesToDownload = LoadingStats.TotalBytesToDownload;
//Get the number of chunks mounted and chunks to download
ChunksMounted = LoadingStats.ChunksMounted;
TotalChunksToMount = LoadingStats.TotalChunksToMount;
//Calculate the download and mount percent using the above stats
DownloadPercent = ((float)BytesDownloaded / (float)TotalBytesToDownload) * 100.0f;
MountPercent = ((float)ChunksMounted / (float)TotalChunksToMount) * 100.0f;
}
bool UPatchingDemoGameInstance::PatchGame()
{
// make sure the download manifest is up to date
if (bIsDownloadManifestUpToDate)
{
// get the chunk downloader
TSharedRef<FChunkDownloader> Downloader = FChunkDownloader::GetChecked();
// report current chunk status
for (int32 ChunkID : ChunkDownloadList)
{
int32 ChunkStatus = static_cast<int32>(Downloader->GetChunkStatus(ChunkID));
UE_LOG(LogTemp, Display, TEXT("Chunk %i status:%i"), ChunkID, ChunkStatus);
}
TFunction<void(bool bSuccess)> DownloadCompleteCallback = [&](bool bSuccess) {OnDownloadComplete(bSuccess); };
Downloader->DownloadChunks(ChunkDownloadList, DownloadCompleteCallback, 1);
// start loading mode
TFunction<void(bool bSuccess)> LoadingModeCompleteCallback = [&](bool bSuccess) {OnLoadingModeComplete(bSuccess); };
Downloader->BeginLoadingMode(LoadingModeCompleteCallback);
return true;
}
// you couldn't contact the server to validate your Manifest, so you can't patch
UE_LOG(LogTemp, Display, TEXT("Manifest Update Failed.Can't patch the game"));
return false;
}
void UPatchingDemoGameInstance::OnLoadingModeComplete(bool bSuccess)
{
OnDownloadComplete(bSuccess);
}
void UPatchingDemoGameInstance::OnMountComplete(bool bSuccess)
{
OnPatchComplete.Broadcast(bSuccess);
}
void UPatchingDemoGameInstance::OnDownloadComplete(bool bSuccess)
{
if (bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Download complete"));
// get the chunk downloader
TSharedRef<FChunkDownloader> Downloader = FChunkDownloader::GetChecked();
FJsonSerializableArrayInt DownloadedChunks;
for (int32 ChunkID : ChunkDownloadList)
{
DownloadedChunks.Add(ChunkID);
}
//Mount the chunks
TFunction<void(bool bSuccess)> MountCompleteCallback = [&](bool bSuccess) {OnMountComplete(bSuccess); };
Downloader->MountChunks(DownloadedChunks, MountCompleteCallback);
OnPatchComplete.Broadcast(true);
}
else
{
UE_LOG(LogTemp, Display, TEXT("Load process failed"));
// call the delegate
OnPatchComplete.Broadcast(false);
}
}
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "UObject/Object.h"
#include "Net/OnlineBlueprintCallProxyBase.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "FindSessionsCallbackProxy.h"
#include "OculusFindSessionsCallbackProxy.generated.h"
/**
* Exposes FindSession of the Platform SDK for blueprint use.
*/
UCLASS(MinimalAPI)
class UOculusFindSessionsCallbackProxy : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
// Called when there is a successful query
UPROPERTY(BlueprintAssignable)
FBlueprintFindSessionsResultDelegate OnSuccess;
// Called when there is an unsuccessful query
UPROPERTY(BlueprintAssignable)
FBlueprintFindSessionsResultDelegate OnFailure;
// Searches for matchmaking room sessions with the oculus online subsystem
UFUNCTION(BlueprintCallable, Category = "Oculus|Session", meta = (BlueprintInternalUseOnly = "true"))
static UOculusFindSessionsCallbackProxy* FindMatchmakingSessions(int32 MaxResults, FString OculusMatchmakingPool);
// Searches for moderated room sessions with the oculus online subsystem
UFUNCTION(BlueprintCallable, Category = "Oculus|Session", meta = (BlueprintInternalUseOnly = "true"))
static UOculusFindSessionsCallbackProxy* FindModeratedSessions(int32 MaxResults);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface
private:
// Internal callback when the session search completes, calls out to the public success/failure callbacks
void OnCompleted(bool bSuccess);
private:
// The delegate executed by the online subsystem
FOnFindSessionsCompleteDelegate Delegate;//デリゲート宣言
// Handle to the registered OnFindSessionsComplete delegate
FDelegateHandle DelegateHandle;//デリゲートハンドル宣言
// Object to track search results
TSharedPtr<FOnlineSessionSearch> SearchObject;
// Maximum number of results to return
int MaxResults;
// Optional: if searching within a matchmaking pool
FString OculusPool;
bool bSearchModeratedRoomsOnly;
};
// 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')