#author("2024-09-04T08:23:48+00:00","default:iseki","iseki")
#author("2024-09-04T08:24:13+00:00","default:iseki","iseki")
* VC++ for Unreal Engine

** Pipeline
- https://docs.unrealengine.com/5.3/ja/importing-assets-using-interchange-in-unreal-engine/

** Plugin
- 拡張機能はプラグインとなる



*** Runtime with EditorSubsystem
**** Unreal
+ 空のプロジェクトを C++ で作成
+ 「編集」->「プラグイン」
++ Visual Studio Integration Tools プラグインを有効化.再起動.
++ 「+追加」: 空のプラグインを作る.(PTest)
**** Visual Studio
+ PTest.uplugin を編集
+ ''uplugin ファイル'' にターゲットを記述 (''Win64'' とか),Type を ''Editor'', Installed を true (?) にする.時々リセットされる?
<pre>
"Installed": true,
"Modules": [
    {
        "Name": "Plugin Test",
        "Type": "Editor",
        "LoadingPhase": "Default",
        "WhitelistPlatforms" : [
            "Win64",
        ]
    }
</pre>
**** Unreal
+ ''出力ログを表示させて(ウィンドウ->出力ログ),一度 プラグインをパッケージ化してみる(プラグインの画面で,各パッケージから「パッケージ」を選択).''  <- ''再コンパイルする場合はここから''
+ ''出力ログを表示させて(ウィンドウ->出力ログ),一度 プラグインをパッケージ化してみる(プラグインの画面で,各パッケージから「パッケージ」を選択).''  
++ ↑''再コンパイルする場合はここから''
+ Android用の DLLが無いとかいろいろ言われる場合は,Epic Games LauncherからUEを認証し直してみる.

**** Visual Studio
+ ''PTest.Build.cs'' ファイルの PrivateDependencyModuleNames に依存モジュール名を追加.
<pre>
"EditorSubsystem",
"StaticMeshEditor",
"UnrealEd"            // Editor 以外で使用できない
</pre>

**** Unreal
+ UE のツールから 新規 C++クラス... を選択
+「全てのクラス」を選択し,テンプレートとなるクラスを選択(EditorSubsystem).
+ クラスタイプは ''パブリック'',ファイル名の横の ''ターゲットモジュール''で作成したプラグインを選択.''パス'' 注意.

**** 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.exe) から入れる (25.1.8937393)
-- 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 FString."));

- 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"), *(CreatedObject->GetName()));

*** オブジェクトの中心
<pre>
FVector center1 = mesh->GetBounds().GetSphere().Center;
FVector center2 = mesh->GetBoundingBox().GetCenter();
</pre>

** Material
*** Material の変更を永続的にする.
- Staticメッシュ,Staticマテリアル   : パラメータを変更できない.
- Dynamicメッシュ,Dynamicマテリアル : パラメータを変更できる(ただし一時的).

+ BPのマテリアルモデルから MaterialInterface を作って,Staticマテリアルとして Static メッシュに登録する.// Staticだと思わせておいて,
+ Static メッシュ から,Dynamic マテリアルインターフェイスを作ってパラメータを調整する.
+ Dynamic マテリアルインターフェイスを,Staicメッシュのマテリアルに登録する.                            // Dynamic を設定する!
 
** 雑メモ
*** まともにいごきたるもの
- Subsystem たるもの
- メニューにつけたるボタンプラグインといふべきもの
*** 訳わからん エラー
**** 急に Pluginの出力ができなくなる.
- Android用の DLLが無いとかいろいろ言われる場合は,Epic Games LauncherからUEを認証し直してみる.
**** C++: 不完全クラス型へのポインターは使用できません
- 必要なヘッダをインクルードしていない.

**** C++: 何か足りない関連のエラー
- 親クラスを継承した空クラスを作りまくる.
-- システムがその辺の環境を勝手に揃える(何を揃えているのか さっぱりさっぱり)
**** Plugin の書き出し: Remote compiling requires a server name. Use the editor (Project Settings > IOS) to set up your remote compilation settings.
- 俺は IOS用のプラグインを作るつもりは毛頭ないんだが.... プロジェクト設定で サーバ名を指定しろとか... 何言ってんの?
- ターゲットはホワイトリスト方式とか,初見殺しか!  ''~.uplugin'' に記述する.
- 下の ''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->GetEditorSubsystem<UStaticMeshEditorSubsystem>();
UEditorActorSubsystem* ea = GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
UActorEditorContextSubsystem* ac = GEditor->GetEditorSubsystem<UActorEditorContextSubsystem>();
UAssetEditorSubsystem* ae = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
UAssetEditorUISubsystem* ui = GEditor->GetEditorSubsystem<UAssetEditorUISubsystem>();
UEditorAssetSubsystem* aa = GEditor->GetEditorSubsystem<UEditorAssetSubsystem>();
</pre>



** 雑コード
*** Menu Button Plugin

<pre>
void FPButtonModule::PluginButtonClicked()
{
    TArray<AActor*> actors;
    UWorld* World = GEditor->GetEditorWorldContext().World();
    UGameplayStatics::GetAllActorsOfClass(World, AActor::StaticClass(), actors); 
    for (AActor* act : actors) {
        FString _class_name = act->GetClass()->GetName();
        if (_class_name.Find(TEXT("StaticMeshActor")) == 0) {
            AStaticMeshActor* satr = Cast<AStaticMeshActor>(act);
            UStaticMeshComponent* cmp = satr->GetStaticMeshComponent();
            UStaticMesh* mesh = cmp->GetStaticMesh();
            UE_LOG(LogTemp, Log, TEXT("MESH NAME = %s %s"), *mesh->GetName());
            FVector vv(1000., 1000., 100000.);
            act->SetActorLocation(vv);
        }
    }
}
</pre>


*** Subsystem Test (死屍累々)
**** MyEditorSubsystem.cpp
<pre>
// Fill out your copyright notice in the Description page of Project Settings.

#include "MyEditorSubsystem.h"
#include "Subsystems/EditorAssetSubsystem.h"
void UMyEditorSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
    Super::Initialize(Collection);
    //static FName ImporterRulesAppliedName = FName(TEXT("importer_rules_applied"));
    //static FString TrueString = FString(TEXT("True"));

    //SetImportedAssetTagAction = NewObject<UIRActionSetAssetTags>();
    //SetImportedAssetTagAction->AssetTags.Add(ImporterRulesAppliedName, TrueString);
    //CheckImportedAssetTagAction = NewObject<UIRQueryCheckAssetTag>();
    //CheckImportedAssetTagAction->AssetTagKey = ImporterRulesAppliedName;
    //CheckImportedAssetTagAction->AssetTagValue = TrueString;

    if (GEditor == NULL) return;
    UImportSubsystem* ImportSubsystem = GEditor->GetEditorSubsystem<UImportSubsystem>();
    
    if (ImportSubsystem!=NULL)
    {
        OnAssetPostImportHandle = ImportSubsystem->OnAssetPostImport.AddUObject(this, &UMyEditorSubsystem::OnAssetPostImport);

        /*
        ImportSubsystem->OnAssetPostImport.AddLambda([this](UFactory* Factory, UObject* CreatedObject)
            {
                //UE_LOG(LogTemp, Log, TEXT("UMyEditorSubsystem::Deinitialize()"));
                //UE_LOG(LogTemp, Log, TEXT("================================================"));
            
                if (Factory != NULL) {
                    FName _name = Factory->GetFName();
                    UE_LOG(LogTemp, Log, TEXT("==> %s"), *_name.ToString());
                }
                else {
                    //UE_LOG(LogTemp, Log, TEXT("Factory is NULL"))
                }

                //UMaterialEditorMeshComponent* xxx = (UMaterialEditorMeshComponent*)CreatedObject;
                //xxx->Set
                UEditorAssetSubsystem* EditorAssetSubsystem = GEditor->GetEditorSubsystem<UEditorAssetSubsystem>();

                if (CreatedObject != NULL) {
                    FString _name = CreatedObject->GetName();
                    //UE_LOG(LogTemp, Log, TEXT("SSS> %s"), *_name);
                    if (_name.Find(FString(TEXT("MATERIAL_"))) == 0) {
                        UE_LOG(LogTemp, Log, TEXT("GGGGGGGGGGGGGGGGGGGGGGGG> %s"), *_name);
                        //UMaterialInstanceDynamic* material = (UMaterialInstanceDynamic*)CreatedObject;
                        //UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);
                        //CreatedObject = ma
                        //material->SetVectorParameterValue(FName(TEXT("BaseColor")), FLinearColor(1.0f, 0.0f, 0.0f));
                        //UMaterialInstance* material = (UMaterialInstance*)CreatedObject;
                        //*CreatedObject = *material;
                        //UMaterialInstance* material = (UMaterialInstance*)CreatedObject;

                        //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("diffuse_color")), TEXT("{R:1.0, G:0.0, B:0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("base_color")), TEXT("{R:1.0, G:0.0, B:0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("BaseColor")), TEXT("{R:1.0, G:0.0, B:0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("DiffuseColor")), TEXT("{R:1.0, G:0.0, B:0.0}"));
                        
                        //FString _tag;
                        //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "BaseColor");
                        //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
                        //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "Color");
                        //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
                        //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "DiffuseColor");
                        //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
                        //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "base_color");
                        //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
                        //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "diffuse_color");
                        //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
                    
                        //CreatedObject->Modify();

                        //UMaterial* material = (UMaterial*)CreatedObject;
                        //material->Set
                        
                        //UMaterialInstanceDynamic* material = Cast<UMaterialInstanceDynamic>(CreatedObject);
                        //UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);
                        //material->SetVectorParameterValue(FName(TEXT("Base Color")), FLinearColor(1.0f, 0.0f, 0.0f));

                        //UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);

                        //material->Modify();
                        
                        //material->SetVectorParameterValue(FName(TEXT("Base Color")), FLinearColor(1.0f, 0.0f, 0.0f));

                        //CreatedObject->Modify();
                        //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("diffuse_color")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("Input DiffuseColor")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("Input DiffuseColor (Vector3)")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("base_color")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
                        //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("BaseColor")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
                        
                        //TMap<FName, FString> _maps = EditorAssetSubsystem->GetMetadataTagValues(material);
                        //for (auto& aaa : _maps) {
                        //    UE_LOG(LogTemp, Log, TEXT("xxxxxxxxxxxxxxx> %s  %s"), *(aaa.Key).ToString(), *aaa.Value);
                        //}
                    }
                }
                //UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));
                
                //check(IsValid(CheckImportedAssetTagAction) && IsValid(SetImportedAssetTagAction));
                //const bool bIsReimport = CheckImportedAssetTagAction->Test(Factory, CreatedObject);
                //UImporterRulesDeveloperSettings* DeveloperSettings = GetMutableDefault<UImporterRulesDeveloperSettings>();
                //check(IsValid(DeveloperSettings));
                for (auto RulesIt = DeveloperSettings->RegisteredRules.CreateIterator(); RulesIt; ++RulesIt)
                {
                    if (CreatedObject->IsA(RulesIt.Key()))
                    {
                        for (const auto Rule : RulesIt.Value().Rules)
                        {
                            if (!bIsReimport || Rule->bApplyOnReimport)
                            {
                                Rule->Apply(Factory, CreatedObject);
                            }
                        }
                    }
                }
            }
        );*/
    }
}

void UMyEditorSubsystem::OnAssetPostImport(UFactory* Factory, UObject* CreatedObject)
{
    if (CreatedObject != NULL) {
        FString _namexx = CreatedObject->GetName();
        UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAAAAAAAAA> %s"), *_namexx);

        FString _classxx = CreatedObject->GetClass()->GetName(); // Material
        UE_LOG(LogTemp, Log, TEXT("class -=========> %s"), *_classxx);

        if (_classxx.Equals(FString(TEXT("StaticMesh")))) {
            UE_LOG(LogTemp, Log, TEXT("AAAAAAAAAAAAAAAAAAAAAAAAA> %s"), *_namexx);
            UE_LOG(LogTemp, Log, TEXT("class -=========> %s"), *_classxx);

            UStaticMesh* mesh = Cast<UStaticMesh>(CreatedObject);

            //CreatedObject->GetAssetRegistryTags(asset);
            //for (auto& aaa : masset) {
                //aaa.ToSt

            /*
            //TArray
            TArray<FStaticMaterial> smat = mesh->GetStaticMaterials();
            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 -=========> %d: %s"),i, *mname);

                UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(matif, NULL);
                material->SetVectorParameterValue(FName(TEXT("BaseColor")), FLinearColor(0.0f, 0.0f, 1.0f));
                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 -=========> %d: %s"), i, *mname);

                UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(matif, NULL);
                material->SetVectorParameterValue(FName(TEXT("DeffuseColor")), FLinearColor(0.0f, 0.0f, 1.0f));
                material->SetVectorParameterValue(FName(TEXT("base_color")), FLinearColor(0.0f, 0.0f, 1.0f));
                
                //UStaticMeshSocket 
                //mesh->AddSocket()
                //mesh->SetMaterial(i, material);
                i++;
                //delete &mat;
                matif = mesh->GetMaterial(i);
            }

            /*
            //UMaterialInterface* matif = mesh->GetMaterial(0);
            auto* matif = mesh->GetMaterial(0);
            FString mname = matif->GetName();
            UE_LOG(LogTemp, Log, TEXT("material -=========> %s"), *mname);
            UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(matif, NULL);
            material->SetVectorParameterValue(FName(TEXT("BaseColor")), FLinearColor(1.0f, 0.0f, 0.0f));
            //material->SetVectorParameterValue(FName(TEXT("DiffuseColor")), FLinearColor(1.0f, 0.0f, 0.0f));
            //material->SetVectorParameterValue(FName(TEXT("Color")), FLinearColor(1.0f, 0.0f, 0.0f));

            mesh->SetMaterial(0, material);
            */
        }

        /*
        //UE_LOG(LogTemp, Log, TEXT("SSS> %s"), *_name);
        if (_namexx.Find(FString(TEXT("MATERIAL_"))) == 0) {
            UE_LOG(LogTemp, Log, TEXT("GGGGGGGGGGGGGGGGGGGGGGGG> %s"), *_namexx);

            //UEditorAssetSubsystem* EditorAssetSubsystem = GEditor->GetEditorSubsystem<UEditorAssetSubsystem>();

            //UMaterialInstanceDynamic* material = (UMaterialInstanceDynamic*)CreatedObject;
            //UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);
            //CreatedObject = ma
            //material->SetVectorParameterValue(FName(TEXT("BaseColor")), FLinearColor(1.0f, 0.0f, 0.0f));
            //UMaterialInstance* material = (UMaterialInstance*)CreatedObject;
            //CreatedObject = *material;
            //UMaterialInstance* material = (UMaterialInstance*)CreatedObject;

            //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("diffuse_color")), TEXT("{R:1.0, G:0.0, B:0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("base_color")), TEXT("{R:1.0, G:0.0, B:0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("BaseColor")), TEXT("{R:1.0, G:0.0, B:0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(CreatedObject, FName(TEXT("DiffuseColor")), TEXT("{R:1.0, G:0.0, B:0.0}"));

            //FString _tag;
            //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "BaseColor");
            //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
            //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "Color");
            //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
            //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "DiffuseColor");
            //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
            //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "base_color");
            //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);
            //_tag = EditorAssetSubsystem->GetMetadataTag(CreatedObject, "diffuse_color");
            //UE_LOG(LogTemp, Log, TEXT("TTTTTTTTTTTTTTTTTTTTTTTTT> %s"), *_tag);

            //CreatedObject->Modify();
            //UMaterial* material = (UMaterial*)CreatedObject;
            //material->Set

            FString _class = CreatedObject->GetClass()->GetName(); // Material
            UE_LOG(LogTemp, Log, TEXT("class -=========> %s"), *_class);
            //material->
            //FMaterialCompiler* xxxx = new FMaterialCompiler();

            UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);
            material->SetVectorParameterValue(FName(TEXT("Base Color")), FLinearColor(1.0f, 0.0f, 0.0f));

            //FName _sname = CreatedObject->SourceFileTagName();
            FAssetData asset;
            //TArray<UObject::FAssetRegistryTag> masset;
            CreatedObject->GetAssetRegistryTags(asset);
            
            //for (auto& aaa : masset) {
                //aaa.ToSt
            
            //CreatedObject->Ass
            //UE_LOG(LogTemp, Log, TEXT("====================> %s"), *(masset.ToString()));
            
            //asset.key
            //UE_LOG(LogTemp, Log, TEXT("====================> %s"), *_sname.ToString());

            //FAssetData
            //CreatedObject->GetMate
            //UMaterialInstanceDynamic* material = UMaterialInstanceDynamic::Create(NULL, CreatedObject);

            //material->Modify();
            //material->SetVectorParameterValue(FName(TEXT("Base Color")), FLinearColor(1.0f, 0.0f, 0.0f));
            //CreatedObject->Modify();
            //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("diffuse_color")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("Input DiffuseColor")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("Input DiffuseColor (Vector3)")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("base_color")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));
            //EditorAssetSubsystem->SetMetadataTag(material, FName(TEXT("BaseColor")), TEXT("{\"R\":1.0, \"G\":0.0, \"B\":0.0}"));

            //TMap<FName, FString> _maps = EditorAssetSubsystem->GetMetadataTagValues(material);
            //for (auto& aaa : _maps) {
            //    UE_LOG(LogTemp, Log, TEXT("xxxxxxxxxxxxxxx> %s  %s"), *(aaa.Key).ToString(), *aaa.Value);
            //}
        }*/
    }
    //UE_LOG(LogTemp, Log, TEXT("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));

}


void UMyEditorSubsystem::Deinitialize()
{
    if (GEditor!=NULL)
    {
        UImportSubsystem* ImportSubsystem = GEditor->GetEditorSubsystem<UImportSubsystem>();
        if (ImportSubsystem!=NULL)
        {
            ImportSubsystem->OnAssetPostImport.Remove(OnAssetPostImportHandle);
        }
    }
    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 UEditorSubsystem
{
    GENERATED_BODY()

    //const TMap<FName, FString> _maps;

public:
    // Begin UEditorSubsystem Interface
    virtual void Initialize(FSubsystemCollectionBase& Collection) override;
    virtual void Deinitialize() override;
    // End UEditorSubsystem Interface

    FDelegateHandle OnAssetPostImportHandle;

    //UPROPERTY(Transient)
    void OnAssetPostImport(UFactory* Factory, UObject* CreatedObject);
    
};
</pre>

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 ページ一覧 検索 最終更新   ヘルプ   最終更新のRSS