0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【UE,C++メモ -3- 】コンテンツドロワー内の要素を取得

Posted at

コンストラクタで取得

#include "Kismet/GameplayStatics.h"

// マテリアルインスタンスを取得
static ConstructorHelpers::FObjectFinder<UMaterialInstance> MaterialInsance(TEXT("/Game/Materials/ExampleMaterial.ExampleMaterial"));
if (MaterialInsance.Succeeded())
{
    MyMesh->SetMaterial(0, MaterialInstance.Object);
}

// スタティックメッシュを取得
MyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMesh(TEXT("/Game/StaticMesh/SM_hoge.SM_hoge"));
if (StaticMesh.Succeeded())
{
	MyMesh->SetStaticMesh(StaticMesh.Object);
}

この記述は必ずコンストラクタで実装しよう!!
自信は無いが..
staticで生成することで、クラスに紐づかなくなるので、消えることがないデータとして保持することができているはず。
BPに変換して、エディタ上で変換した方がやりやすいと思う。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?