Unreal_Engine/VC++
をテンプレートにして作成
[
トップ
] [
タイトル一覧
|
ページ一覧
|
新規
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* VC++ for Unreal Engine
** Pipeline
- https://docs.unrealengine.com/5.3/ja/importing-assets-u...
** Plugin
- 拡張機能はプラグインとなる
*** Runtime with EditorSubsystem
**** Unreal
+ 空のプロジェクトを C++ で作成
+ 「編集」->「プラグイン」
++ Visual Studio Integration Tools プラグインを有効化.再...
++ 「+追加」: 空のプラグインを作る.(PTest)
**** Visual Studio
+ PTest.uplugin を編集
+ ''uplugin ファイル'' にターゲットを記述 (''Win64'' とか...
<pre>
"Installed": true,
"Modules": [
{
"Name": "Plugin Test",
"Type": "Editor",
"LoadingPhase": "Default",
"WhitelistPlatforms" : [
"Win64",
]
}
</pre>
**** Unreal
+ ''出力ログを表示させて(ウィンドウ->出力ログ),一度 プ...
++ ↑''再コンパイルする場合はここから''
+ Android用の DLLが無いとかいろいろ言われる場合は,Epic G...
**** Visual Studio
+ ''PTest.Build.cs'' ファイルの PrivateDependencyModuleNa...
<pre>
"EditorSubsystem",
"StaticMeshEditor",
"UnrealEd" // Editor 以外で使用できない
</pre>
**** Unreal
+ UE のツールから 新規 C++クラス... を選択
+「全てのクラス」を選択し,テンプレートとなるクラスを選択...
+ クラスタイプは ''パブリック'',ファイル名の横の ''ター...
**** Visual Studio
+ UE を修了させ,Visual Studioでビルド.
+ UE を終了しないと,Visual Studioでビルドがエラーになる
**** Unreal
+ ''出力ログを表示させて,一度 プラグインをパッケージ化し...
*** Editor
*** Android
**** JDK, NDK
- JDK: jdk-8u202-windows-x64.exe
- NDK: Android Studio (android-studio-2023.1.1.28-windows...
-- https://www.youtube.com/watch?v=ypR_YsnJaJo
*** FSetLocationByParameterModule 更新
- Tool -> Open Visual Studio
- VSでソース修正
- UE を止める
- VSでビルド(エラーが出る場合は,リビルドしてみる)
- Editor -> Plugins
-- Package ボタンでパッケージを作る.
** C++クラス
*** マクロ
**** MYPROJECT_API
#define MYPROJECT_API DLLEXPORT
- DLLEXPORT と書き換えるとエラー.DllExport じゃね?
*** FName
<pre>
FName _name = ......;
UE_LOG(LogTemp, Log, TEXT("==> %s"), *_name.ToString());
</pre>
*** FString
<pre>
FString _str = ......;
UE_LOG(LogTemp, Log, TEXT("==> %s"), *_str);
</pre>
FString TestHUDString = FString(TEXT("This is my test FS...
- Equals()
- Find()
- Contains()
**** 文字変換
<pre>
params_str = params_str.Replace(TEXT("-"), TEXT("/"));
</pre>
**** char* 変換
<pre>
FSTring _name = ....;
FString mpath = FString(TEXT("/Game/OBJ/")) + _name;
UE_LOG(LogTemp, Log, TEXT("material = %s"), *mpath);
::remove(TCHAR_TO_ANSI (*mpath));
</pre>
*** Log
UE_LOG(LogTemp, Log, TEXT("material = %s"), *(CreatedObj...
*** オブジェクトの中心
<pre>
FVector center1 = mesh->GetBounds().GetSphere().Center;
FVector center2 = mesh->GetBoundingBox().GetCenter();
</pre>
** Material
*** Material の変更を永続的にする.
- Staticメッシュ,Staticマテリアル : パラメータを変更で...
- Dynamicメッシュ,Dynamicマテリアル : パラメータを変更...
+ BPのマテリアルモデルから MaterialInterface を作って,St...
+ Static メッシュ から,Dynamic マテリアルインターフェイ...
+ Dynamic マテリアルインターフェイスを,Staicメッシュのマ...
** 雑メモ
*** まともにいごきたるもの
- Subsystem たるもの
- メニューにつけたるボタンプラグインといふべきもの
*** 訳わからん エラー
**** 急に Pluginの出力ができなくなる.
- Android用の DLLが無いとかいろいろ言われる場合は,Epic G...
**** C++: 不完全クラス型へのポインターは使用できません
- 必要なヘッダをインクルードしていない.
**** C++: 何か足りない関連のエラー
- 親クラスを継承した空クラスを作りまくる.
-- システムがその辺の環境を勝手に揃える(何を揃えているの...
**** Plugin の書き出し: Remote compiling requires a serve...
- 俺は IOS用のプラグインを作るつもりは毛頭ないんだが.... ...
- ターゲットはホワイトリスト方式とか,初見殺しか! ''~.u...
- 下の ''Win64'' がターゲットプラットフォーム
<pre>
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "OARSelectMaterial",
"Description": "",
"Category": "Other",
"CreatedBy": "Fumi.Iseki",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "OARSelectMaterial",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
]
}
]
}
</pre>
*** Actor
<pre>
AActor* act = Cast<AActor>(CreatedObject);
act->SetActorLocation(...);
</pre>
*** Subsystem
<pre>
#include "Subsystems/EditorAssetSubsystem.h"
#include <Subsystems/AssetEditorSubsystem.h>
#include <Subsystems/ActorEditorContextSubsystem.h>
#include <Toolkits/AssetEditorModeUILayer.h>
#include <TransformMeshesTool.h>
UStaticMeshEditorSubsystem* me = GEditor->GetEditorSubsys...
UEditorActorSubsystem* ea = GEditor->GetEditorSubsystem<U...
UActorEditorContextSubsystem* ac = GEditor->GetEditorSubs...
UAssetEditorSubsystem* ae = GEditor->GetEditorSubsystem<U...
UAssetEditorUISubsystem* ui = GEditor->GetEditorSubsystem...
UEditorAssetSubsystem* aa = GEditor->GetEditorSubsystem<U...
</pre>
** 雑コード
*** Menu Button Plugin
<pre>
void FPButtonModule::PluginButtonClicked()
{
TArray<AActor*> actors;
UWorld* World = GEditor->GetEditorWorldContext().Worl...
UGameplayStatics::GetAllActorsOfClass(World, AActor::...
for (AActor* act : actors) {
FString _class_name = act->GetClass()->GetName();
if (_class_name.Find(TEXT("StaticMeshActor")) == ...
AStaticMeshActor* satr = Cast<AStaticMeshActo...
UStaticMeshComponent* cmp = satr->GetStaticMe...
UStaticMesh* mesh = cmp->GetStaticMesh();
UE_LOG(LogTemp, Log, TEXT("MESH NAME = %s %s"...
FVector vv(1000., 1000., 100000.);
act->SetActorLocation(vv);
}
}
}
</pre>
*** Subsystem Test (死屍累々)
**** MyEditorSubsystem.cpp
<pre>
// Fill out your copyright notice in the Description page...
#include "MyEditorSubsystem.h"
#include "Subsystems/EditorAssetSubsystem.h"
void UMyEditorSubsystem::Initialize(FSubsystemCollectionB...
{
Super::Initialize(Collection);
//static FName ImporterRulesAppliedName = FName(TEXT(...
//static FString TrueString = FString(TEXT("True"));
//SetImportedAssetTagAction = NewObject<UIRActionSetA...
//SetImportedAssetTagAction->AssetTags.Add(ImporterRu...
//CheckImportedAssetTagAction = NewObject<UIRQueryChe...
//CheckImportedAssetTagAction->AssetTagKey = Importer...
//CheckImportedAssetTagAction->AssetTagValue = TrueSt...
if (GEditor == NULL) return;
UImportSubsystem* ImportSubsystem = GEditor->GetEdito...
if (ImportSubsystem!=NULL)
{
OnAssetPostImportHandle = ImportSubsystem->OnAsse...
/*
ImportSubsystem->OnAssetPostImport.AddLambda([thi...
{
//UE_LOG(LogTemp, Log, TEXT("UMyEditorSub...
//UE_LOG(LogTemp, Log, TEXT("============...
if (Factory != NULL) {
FName _name = Factory->GetFName();
UE_LOG(LogTemp, Log, TEXT("==> %s"), ...
}
else {
//UE_LOG(LogTemp, Log, TEXT("Factory ...
}
//UMaterialEditorMeshComponent* xxx = (UM...
//xxx->Set
UEditorAssetSubsystem* EditorAssetSubsyst...
if (CreatedObject != NULL) {
FString _name = CreatedObject->GetNam...
//UE_LOG(LogTemp, Log, TEXT("SSS> %s"...
if (_name.Find(FString(TEXT("MATERIAL...
UE_LOG(LogTemp, Log, TEXT("GGGGGG...
//UMaterialInstanceDynamic* mater...
//UMaterialInstanceDynamic* mater...
//CreatedObject = ma
//material->SetVectorParameterVal...
//UMaterialInstance* material = (...
//*CreatedObject = *material;
//UMaterialInstance* material = (...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//FString _tag;
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//CreatedObject->Modify();
//UMaterial* material = (UMateria...
//material->Set
//UMaterialInstanceDynamic* mater...
//UMaterialInstanceDynamic* mater...
//material->SetVectorParameterVal...
//UMaterialInstanceDynamic* mater...
//material->Modify();
//material->SetVectorParameterVal...
//CreatedObject->Modify();
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//TMap<FName, FString> _maps = Ed...
//for (auto& aaa : _maps) {
// UE_LOG(LogTemp, Log, TEXT("...
//}
}
}
//UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXX...
//check(IsValid(CheckImportedAssetTagActi...
//const bool bIsReimport = CheckImportedA...
//UImporterRulesDeveloperSettings* Develo...
//check(IsValid(DeveloperSettings));
for (auto RulesIt = DeveloperSettings->Re...
{
if (CreatedObject->IsA(RulesIt.Key()))
{
for (const auto Rule : RulesIt.Va...
{
if (!bIsReimport || Rule->bAp...
{
Rule->Apply(Factory, Crea...
}
}
}
}
}
);*/
}
}
void UMyEditorSubsystem::OnAssetPostImport(UFactory* Fact...
{
if (CreatedObject != NULL) {
FString _namexx = CreatedObject->GetName();
UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAAAAAA...
FString _classxx = CreatedObject->GetClass()->Get...
UE_LOG(LogTemp, Log, TEXT("class -=========> %s")...
if (_classxx.Equals(FString(TEXT("StaticMesh")))) {
UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAA...
UE_LOG(LogTemp, Log, TEXT("class -=========> ...
UStaticMesh* mesh = Cast<UStaticMesh>(Created...
//CreatedObject->GetAssetRegistryTags(asset);
//for (auto& aaa : masset) {
//aaa.ToSt
/*
//TArray
TArray<FStaticMaterial> smat = mesh->GetStati...
int i = 0;
for (auto& mat : smat) {
//auto* matif = mesh->GetMaterial(i);
//FString mname = matif->GetName();
auto matif = mat.MaterialInterface;
FString mname = matif.GetName();
UE_LOG(LogTemp, Log, TEXT("material -====...
UMaterialInstanceDynamic* material = UMat...
material->SetVectorParameterValue(FName(T...
mesh->SetMaterial(i, material);
i++;
//delete &mat;
}
//mesh->SetStaticMaterials(smat);
*/
int i = 0;
auto* matif = mesh->GetMaterial(i);
while (matif != NULL)
{
FString mname = matif->GetName();
//auto matif = mat.MaterialInterface;
//FString mname = matif.GetName();
UE_LOG(LogTemp, Log, TEXT("material -====...
UMaterialInstanceDynamic* material = UMat...
material->SetVectorParameterValue(FName(T...
material->SetVectorParameterValue(FName(T...
//UStaticMeshSocket
//mesh->AddSocket()
//mesh->SetMaterial(i, material);
i++;
//delete &mat;
matif = mesh->GetMaterial(i);
}
/*
//UMaterialInterface* matif = mesh->GetMateri...
auto* matif = mesh->GetMaterial(0);
FString mname = matif->GetName();
UE_LOG(LogTemp, Log, TEXT("material -========...
UMaterialInstanceDynamic* material = UMateria...
material->SetVectorParameterValue(FName(TEXT(...
//material->SetVectorParameterValue(FName(TEX...
//material->SetVectorParameterValue(FName(TEX...
mesh->SetMaterial(0, material);
*/
}
/*
//UE_LOG(LogTemp, Log, TEXT("SSS> %s"), *_name);
if (_namexx.Find(FString(TEXT("MATERIAL_"))) == 0...
UE_LOG(LogTemp, Log, TEXT("GGGGGGGGGGGGGGGGGG...
//UEditorAssetSubsystem* EditorAssetSubsystem...
//UMaterialInstanceDynamic* material = (UMate...
//UMaterialInstanceDynamic* material = UMater...
//CreatedObject = ma
//material->SetVectorParameterValue(FName(TEX...
//UMaterialInstance* material = (UMaterialIns...
//CreatedObject = *material;
//UMaterialInstance* material = (UMaterialIns...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//FString _tag;
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//CreatedObject->Modify();
//UMaterial* material = (UMaterial*)CreatedOb...
//material->Set
FString _class = CreatedObject->GetClass()->G...
UE_LOG(LogTemp, Log, TEXT("class -=========> ...
//material->
//FMaterialCompiler* xxxx = new FMaterialComp...
UMaterialInstanceDynamic* material = UMateria...
material->SetVectorParameterValue(FName(TEXT(...
//FName _sname = CreatedObject->SourceFileTag...
FAssetData asset;
//TArray<UObject::FAssetRegistryTag> masset;
CreatedObject->GetAssetRegistryTags(asset);
//for (auto& aaa : masset) {
//aaa.ToSt
//CreatedObject->Ass
//UE_LOG(LogTemp, Log, TEXT("================...
//asset.key
//UE_LOG(LogTemp, Log, TEXT("================...
//FAssetData
//CreatedObject->GetMate
//UMaterialInstanceDynamic* material = UMater...
//material->Modify();
//material->SetVectorParameterValue(FName(TEX...
//CreatedObject->Modify();
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//TMap<FName, FString> _maps = EditorAssetSub...
//for (auto& aaa : _maps) {
// UE_LOG(LogTemp, Log, TEXT("xxxxxxxxxxxx...
//}
}*/
}
//UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXXXXXXXXXXXXXX...
}
void UMyEditorSubsystem::Deinitialize()
{
if (GEditor!=NULL)
{
UImportSubsystem* ImportSubsystem = GEditor->GetE...
if (ImportSubsystem!=NULL)
{
ImportSubsystem->OnAssetPostImport.Remove(OnA...
}
}
Super::Deinitialize();
}
</pre>
**** MyEditorSubsystem.h
<pre>
<pre>
#pragma once
#include "CoreMinimal.h"
#include "EditorSubsystem.h"
#include "MyEditorSubsystem.generated.h"
/**
*
*/
UCLASS(BlueprintType, CollapseCategories)
class MYPROJECT_API UMyEditorSubsystem : public UEditorSu...
{
GENERATED_BODY()
//const TMap<FName, FString> _maps;
public:
// Begin UEditorSubsystem Interface
virtual void Initialize(FSubsystemCollectionBase& Col...
virtual void Deinitialize() override;
// End UEditorSubsystem Interface
FDelegateHandle OnAssetPostImportHandle;
//UPROPERTY(Transient)
void OnAssetPostImport(UFactory* Factory, UObject* Cr...
};
</pre>
終了行:
* VC++ for Unreal Engine
** Pipeline
- https://docs.unrealengine.com/5.3/ja/importing-assets-u...
** Plugin
- 拡張機能はプラグインとなる
*** Runtime with EditorSubsystem
**** Unreal
+ 空のプロジェクトを C++ で作成
+ 「編集」->「プラグイン」
++ Visual Studio Integration Tools プラグインを有効化.再...
++ 「+追加」: 空のプラグインを作る.(PTest)
**** Visual Studio
+ PTest.uplugin を編集
+ ''uplugin ファイル'' にターゲットを記述 (''Win64'' とか...
<pre>
"Installed": true,
"Modules": [
{
"Name": "Plugin Test",
"Type": "Editor",
"LoadingPhase": "Default",
"WhitelistPlatforms" : [
"Win64",
]
}
</pre>
**** Unreal
+ ''出力ログを表示させて(ウィンドウ->出力ログ),一度 プ...
++ ↑''再コンパイルする場合はここから''
+ Android用の DLLが無いとかいろいろ言われる場合は,Epic G...
**** Visual Studio
+ ''PTest.Build.cs'' ファイルの PrivateDependencyModuleNa...
<pre>
"EditorSubsystem",
"StaticMeshEditor",
"UnrealEd" // Editor 以外で使用できない
</pre>
**** Unreal
+ UE のツールから 新規 C++クラス... を選択
+「全てのクラス」を選択し,テンプレートとなるクラスを選択...
+ クラスタイプは ''パブリック'',ファイル名の横の ''ター...
**** Visual Studio
+ UE を修了させ,Visual Studioでビルド.
+ UE を終了しないと,Visual Studioでビルドがエラーになる
**** Unreal
+ ''出力ログを表示させて,一度 プラグインをパッケージ化し...
*** Editor
*** Android
**** JDK, NDK
- JDK: jdk-8u202-windows-x64.exe
- NDK: Android Studio (android-studio-2023.1.1.28-windows...
-- https://www.youtube.com/watch?v=ypR_YsnJaJo
*** FSetLocationByParameterModule 更新
- Tool -> Open Visual Studio
- VSでソース修正
- UE を止める
- VSでビルド(エラーが出る場合は,リビルドしてみる)
- Editor -> Plugins
-- Package ボタンでパッケージを作る.
** C++クラス
*** マクロ
**** MYPROJECT_API
#define MYPROJECT_API DLLEXPORT
- DLLEXPORT と書き換えるとエラー.DllExport じゃね?
*** FName
<pre>
FName _name = ......;
UE_LOG(LogTemp, Log, TEXT("==> %s"), *_name.ToString());
</pre>
*** FString
<pre>
FString _str = ......;
UE_LOG(LogTemp, Log, TEXT("==> %s"), *_str);
</pre>
FString TestHUDString = FString(TEXT("This is my test FS...
- Equals()
- Find()
- Contains()
**** 文字変換
<pre>
params_str = params_str.Replace(TEXT("-"), TEXT("/"));
</pre>
**** char* 変換
<pre>
FSTring _name = ....;
FString mpath = FString(TEXT("/Game/OBJ/")) + _name;
UE_LOG(LogTemp, Log, TEXT("material = %s"), *mpath);
::remove(TCHAR_TO_ANSI (*mpath));
</pre>
*** Log
UE_LOG(LogTemp, Log, TEXT("material = %s"), *(CreatedObj...
*** オブジェクトの中心
<pre>
FVector center1 = mesh->GetBounds().GetSphere().Center;
FVector center2 = mesh->GetBoundingBox().GetCenter();
</pre>
** Material
*** Material の変更を永続的にする.
- Staticメッシュ,Staticマテリアル : パラメータを変更で...
- Dynamicメッシュ,Dynamicマテリアル : パラメータを変更...
+ BPのマテリアルモデルから MaterialInterface を作って,St...
+ Static メッシュ から,Dynamic マテリアルインターフェイ...
+ Dynamic マテリアルインターフェイスを,Staicメッシュのマ...
** 雑メモ
*** まともにいごきたるもの
- Subsystem たるもの
- メニューにつけたるボタンプラグインといふべきもの
*** 訳わからん エラー
**** 急に Pluginの出力ができなくなる.
- Android用の DLLが無いとかいろいろ言われる場合は,Epic G...
**** C++: 不完全クラス型へのポインターは使用できません
- 必要なヘッダをインクルードしていない.
**** C++: 何か足りない関連のエラー
- 親クラスを継承した空クラスを作りまくる.
-- システムがその辺の環境を勝手に揃える(何を揃えているの...
**** Plugin の書き出し: Remote compiling requires a serve...
- 俺は IOS用のプラグインを作るつもりは毛頭ないんだが.... ...
- ターゲットはホワイトリスト方式とか,初見殺しか! ''~.u...
- 下の ''Win64'' がターゲットプラットフォーム
<pre>
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "OARSelectMaterial",
"Description": "",
"Category": "Other",
"CreatedBy": "Fumi.Iseki",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "OARSelectMaterial",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
]
}
]
}
</pre>
*** Actor
<pre>
AActor* act = Cast<AActor>(CreatedObject);
act->SetActorLocation(...);
</pre>
*** Subsystem
<pre>
#include "Subsystems/EditorAssetSubsystem.h"
#include <Subsystems/AssetEditorSubsystem.h>
#include <Subsystems/ActorEditorContextSubsystem.h>
#include <Toolkits/AssetEditorModeUILayer.h>
#include <TransformMeshesTool.h>
UStaticMeshEditorSubsystem* me = GEditor->GetEditorSubsys...
UEditorActorSubsystem* ea = GEditor->GetEditorSubsystem<U...
UActorEditorContextSubsystem* ac = GEditor->GetEditorSubs...
UAssetEditorSubsystem* ae = GEditor->GetEditorSubsystem<U...
UAssetEditorUISubsystem* ui = GEditor->GetEditorSubsystem...
UEditorAssetSubsystem* aa = GEditor->GetEditorSubsystem<U...
</pre>
** 雑コード
*** Menu Button Plugin
<pre>
void FPButtonModule::PluginButtonClicked()
{
TArray<AActor*> actors;
UWorld* World = GEditor->GetEditorWorldContext().Worl...
UGameplayStatics::GetAllActorsOfClass(World, AActor::...
for (AActor* act : actors) {
FString _class_name = act->GetClass()->GetName();
if (_class_name.Find(TEXT("StaticMeshActor")) == ...
AStaticMeshActor* satr = Cast<AStaticMeshActo...
UStaticMeshComponent* cmp = satr->GetStaticMe...
UStaticMesh* mesh = cmp->GetStaticMesh();
UE_LOG(LogTemp, Log, TEXT("MESH NAME = %s %s"...
FVector vv(1000., 1000., 100000.);
act->SetActorLocation(vv);
}
}
}
</pre>
*** Subsystem Test (死屍累々)
**** MyEditorSubsystem.cpp
<pre>
// Fill out your copyright notice in the Description page...
#include "MyEditorSubsystem.h"
#include "Subsystems/EditorAssetSubsystem.h"
void UMyEditorSubsystem::Initialize(FSubsystemCollectionB...
{
Super::Initialize(Collection);
//static FName ImporterRulesAppliedName = FName(TEXT(...
//static FString TrueString = FString(TEXT("True"));
//SetImportedAssetTagAction = NewObject<UIRActionSetA...
//SetImportedAssetTagAction->AssetTags.Add(ImporterRu...
//CheckImportedAssetTagAction = NewObject<UIRQueryChe...
//CheckImportedAssetTagAction->AssetTagKey = Importer...
//CheckImportedAssetTagAction->AssetTagValue = TrueSt...
if (GEditor == NULL) return;
UImportSubsystem* ImportSubsystem = GEditor->GetEdito...
if (ImportSubsystem!=NULL)
{
OnAssetPostImportHandle = ImportSubsystem->OnAsse...
/*
ImportSubsystem->OnAssetPostImport.AddLambda([thi...
{
//UE_LOG(LogTemp, Log, TEXT("UMyEditorSub...
//UE_LOG(LogTemp, Log, TEXT("============...
if (Factory != NULL) {
FName _name = Factory->GetFName();
UE_LOG(LogTemp, Log, TEXT("==> %s"), ...
}
else {
//UE_LOG(LogTemp, Log, TEXT("Factory ...
}
//UMaterialEditorMeshComponent* xxx = (UM...
//xxx->Set
UEditorAssetSubsystem* EditorAssetSubsyst...
if (CreatedObject != NULL) {
FString _name = CreatedObject->GetNam...
//UE_LOG(LogTemp, Log, TEXT("SSS> %s"...
if (_name.Find(FString(TEXT("MATERIAL...
UE_LOG(LogTemp, Log, TEXT("GGGGGG...
//UMaterialInstanceDynamic* mater...
//UMaterialInstanceDynamic* mater...
//CreatedObject = ma
//material->SetVectorParameterVal...
//UMaterialInstance* material = (...
//*CreatedObject = *material;
//UMaterialInstance* material = (...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//FString _tag;
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//_tag = EditorAssetSubsystem->Ge...
//UE_LOG(LogTemp, Log, TEXT("TTTT...
//CreatedObject->Modify();
//UMaterial* material = (UMateria...
//material->Set
//UMaterialInstanceDynamic* mater...
//UMaterialInstanceDynamic* mater...
//material->SetVectorParameterVal...
//UMaterialInstanceDynamic* mater...
//material->Modify();
//material->SetVectorParameterVal...
//CreatedObject->Modify();
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//EditorAssetSubsystem->SetMetada...
//TMap<FName, FString> _maps = Ed...
//for (auto& aaa : _maps) {
// UE_LOG(LogTemp, Log, TEXT("...
//}
}
}
//UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXX...
//check(IsValid(CheckImportedAssetTagActi...
//const bool bIsReimport = CheckImportedA...
//UImporterRulesDeveloperSettings* Develo...
//check(IsValid(DeveloperSettings));
for (auto RulesIt = DeveloperSettings->Re...
{
if (CreatedObject->IsA(RulesIt.Key()))
{
for (const auto Rule : RulesIt.Va...
{
if (!bIsReimport || Rule->bAp...
{
Rule->Apply(Factory, Crea...
}
}
}
}
}
);*/
}
}
void UMyEditorSubsystem::OnAssetPostImport(UFactory* Fact...
{
if (CreatedObject != NULL) {
FString _namexx = CreatedObject->GetName();
UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAAAAAA...
FString _classxx = CreatedObject->GetClass()->Get...
UE_LOG(LogTemp, Log, TEXT("class -=========> %s")...
if (_classxx.Equals(FString(TEXT("StaticMesh")))) {
UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAA...
UE_LOG(LogTemp, Log, TEXT("class -=========> ...
UStaticMesh* mesh = Cast<UStaticMesh>(Created...
//CreatedObject->GetAssetRegistryTags(asset);
//for (auto& aaa : masset) {
//aaa.ToSt
/*
//TArray
TArray<FStaticMaterial> smat = mesh->GetStati...
int i = 0;
for (auto& mat : smat) {
//auto* matif = mesh->GetMaterial(i);
//FString mname = matif->GetName();
auto matif = mat.MaterialInterface;
FString mname = matif.GetName();
UE_LOG(LogTemp, Log, TEXT("material -====...
UMaterialInstanceDynamic* material = UMat...
material->SetVectorParameterValue(FName(T...
mesh->SetMaterial(i, material);
i++;
//delete &mat;
}
//mesh->SetStaticMaterials(smat);
*/
int i = 0;
auto* matif = mesh->GetMaterial(i);
while (matif != NULL)
{
FString mname = matif->GetName();
//auto matif = mat.MaterialInterface;
//FString mname = matif.GetName();
UE_LOG(LogTemp, Log, TEXT("material -====...
UMaterialInstanceDynamic* material = UMat...
material->SetVectorParameterValue(FName(T...
material->SetVectorParameterValue(FName(T...
//UStaticMeshSocket
//mesh->AddSocket()
//mesh->SetMaterial(i, material);
i++;
//delete &mat;
matif = mesh->GetMaterial(i);
}
/*
//UMaterialInterface* matif = mesh->GetMateri...
auto* matif = mesh->GetMaterial(0);
FString mname = matif->GetName();
UE_LOG(LogTemp, Log, TEXT("material -========...
UMaterialInstanceDynamic* material = UMateria...
material->SetVectorParameterValue(FName(TEXT(...
//material->SetVectorParameterValue(FName(TEX...
//material->SetVectorParameterValue(FName(TEX...
mesh->SetMaterial(0, material);
*/
}
/*
//UE_LOG(LogTemp, Log, TEXT("SSS> %s"), *_name);
if (_namexx.Find(FString(TEXT("MATERIAL_"))) == 0...
UE_LOG(LogTemp, Log, TEXT("GGGGGGGGGGGGGGGGGG...
//UEditorAssetSubsystem* EditorAssetSubsystem...
//UMaterialInstanceDynamic* material = (UMate...
//UMaterialInstanceDynamic* material = UMater...
//CreatedObject = ma
//material->SetVectorParameterValue(FName(TEX...
//UMaterialInstance* material = (UMaterialIns...
//CreatedObject = *material;
//UMaterialInstance* material = (UMaterialIns...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//EditorAssetSubsystem->SetMetadataTag(Create...
//FString _tag;
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//_tag = EditorAssetSubsystem->GetMetadataTag...
//UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTT...
//CreatedObject->Modify();
//UMaterial* material = (UMaterial*)CreatedOb...
//material->Set
FString _class = CreatedObject->GetClass()->G...
UE_LOG(LogTemp, Log, TEXT("class -=========> ...
//material->
//FMaterialCompiler* xxxx = new FMaterialComp...
UMaterialInstanceDynamic* material = UMateria...
material->SetVectorParameterValue(FName(TEXT(...
//FName _sname = CreatedObject->SourceFileTag...
FAssetData asset;
//TArray<UObject::FAssetRegistryTag> masset;
CreatedObject->GetAssetRegistryTags(asset);
//for (auto& aaa : masset) {
//aaa.ToSt
//CreatedObject->Ass
//UE_LOG(LogTemp, Log, TEXT("================...
//asset.key
//UE_LOG(LogTemp, Log, TEXT("================...
//FAssetData
//CreatedObject->GetMate
//UMaterialInstanceDynamic* material = UMater...
//material->Modify();
//material->SetVectorParameterValue(FName(TEX...
//CreatedObject->Modify();
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//EditorAssetSubsystem->SetMetadataTag(materi...
//TMap<FName, FString> _maps = EditorAssetSub...
//for (auto& aaa : _maps) {
// UE_LOG(LogTemp, Log, TEXT("xxxxxxxxxxxx...
//}
}*/
}
//UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXXXXXXXXXXXXXX...
}
void UMyEditorSubsystem::Deinitialize()
{
if (GEditor!=NULL)
{
UImportSubsystem* ImportSubsystem = GEditor->GetE...
if (ImportSubsystem!=NULL)
{
ImportSubsystem->OnAssetPostImport.Remove(OnA...
}
}
Super::Deinitialize();
}
</pre>
**** MyEditorSubsystem.h
<pre>
<pre>
#pragma once
#include "CoreMinimal.h"
#include "EditorSubsystem.h"
#include "MyEditorSubsystem.generated.h"
/**
*
*/
UCLASS(BlueprintType, CollapseCategories)
class MYPROJECT_API UMyEditorSubsystem : public UEditorSu...
{
GENERATED_BODY()
//const TMap<FName, FString> _maps;
public:
// Begin UEditorSubsystem Interface
virtual void Initialize(FSubsystemCollectionBase& Col...
virtual void Deinitialize() override;
// End UEditorSubsystem Interface
FDelegateHandle OnAssetPostImportHandle;
//UPROPERTY(Transient)
void OnAssetPostImport(UFactory* Factory, UObject* Cr...
};
</pre>
ページ名: