본문 바로가기
언리얼/기능, 팁 등등 노트

[UE4]코드 상에서 머티리얼 로드

by 개발펭귄 2018. 11. 13.
1
2
3
4
#include "UObject/ConstructorHelpers.h"
 
 
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("에디터 상에서 머티리얼 레퍼런스를 복사하면 
해당 머티리얼의 경로를 가져올 수 있다"));

cs




마우스 커서 데칼 로드 예제

1
2
3
4
5
6
7
8
9
10
11
12
    //Set Cursor Decal
    CursorToWorld = CreateDefaultSubobject<UDecalComponent>("CursorToWorld");
    CursorToWorld->SetupAttachment(RootComponent);
    {
        static ConstructorHelpers::FObjectFinder<UMaterial> DecalMaterialAsset(TEXT("Material'/Game/Materials/M_CursorDecal.M_CursorDecal'"));
        if (DecalMaterialAsset.Succeeded())
        {
            CursorToWorld->SetDecalMaterial(DecalMaterialAsset.Object);
        }
        CursorToWorld->DecalSize = FVector(16.0f, 32.0f, 32.0f);
        CursorToWorld->SetRelativeRotation(FRotator(0.0f, -90.0f, 0.0f).Quaternion());
    }
cs