UWidgetComponent
위젯애셋을 콤포넌트 형태로 3D월드상에 보여주는 컴포넌트
액터에 붙이고, 디테일의
User Interface > Widget Class 를 UMG 로 작업한 위젯을 지정해 주면 된다.
(위젯 타입 WidgetBlueprint 부모는 UMG.UserWidget )
컴포넌트에서 위젯을 참조하기 위해서는
Get User Widget Object 함수를 사용해 위젯 객체를 레퍼런싱 할 수 있다.
UUserWidget* UWidgetComponent::GetUserWidgetObject()
UUserWidget
UObject-UVisual-UWidget-UUserWidget
c++ 클래스 생성시 UserWidget을 상속받아 생성할 수 있는데,
UMG 를 확장하기 위해서는 아래와 같은 절차가 필요하다
모듈추가
ProjectName.Build.cs 파일 PublicDependencyModuleNames 에 "UMG" 를 추가한다.
PrivateDependencyModuleName.AddRange(new string[] { "Slate", "SlateCore" });
블루프린트에서 위젯 블루프린트를 추가하고, 블루프린트 그래프-클래스세팅-디테일을 보면 class options
여기에서 위에 생성한 클래스를 부모로 설정해 준다.
관련헤더
Runtime/UMG/Public/UMG.h
Runtime/UMG/Public/UMGStyle.h
Runtime/UMG/Public/Slate/SObjectWidget.h
Runtime/UMG/Public/IUMGModule.h
Runtime/UMG/Public/Blueprint/UserWidget.h
UButton
UObject - UVisual-UWidget-UPanelWidget-UContentWidget-UButton
유저위젯 교체
다른 액터의 위젯(위젯 콤포넌트)의 위젯블루프린트(유저위젯) 교체하기
Get All Actors Of Class 나 변수로 지정해 두던 해당 액터를 찾고, 해당 액터에서
Widget Component 클래스를 가져온다.
Create Widget : 생성할 위젯명과 플레이어 객체
Widget Component 의 Set Widget 호출
삭제 : Remove from Parent
입력모드 :
Set Input Mode Game and UI
Set Input Mode Game Only
Set Input Mode UIOnly
c++ 관련 메쏘드
액터
static void UGameplayStatics::GetAllActorsOfClass(
const UObject* WorldContext, // GetWorld()
TSubclassOf<AActor> ActorClass, // MyClass::StaticClass()
TArray<AActor*> &OutActors // Result List
)
콤포넌트
UActorComponent* AActor::FindComponentByClass( const TSubclassOf<UActorComponent> ComponentClass )
플레이어 컨트롤러
static UGameplayStatics::GetPlayerController(
const UObject* WorldContext,
int32 PlayerIndex;
)
or
GetWorld()->GetFirstPlayerController()
위젯 생성
T* CreateWidget(
APlyerController* OwningPlayer,
UClass* UserWidgetClass
)
UMG모듈
Runtime/UMG/Public/Blueprint/UserWidget.h
위젯 지정
void UWidgetComponent::SetWidget( UUserWidget* Widget)
'프로그래밍 > Unreal' 카테고리의 다른 글
[UE4] 관람자 화면 (0) | 2018.01.04 |
---|---|
[UE4] 동적 텍스처 (0) | 2017.12.18 |
[UE4] 디버그 로그 출력 (0) | 2017.11.13 |
[UE4] 유리 매터리얼 (0) | 2017.10.15 |
[UE4] 레벨 스트리밍 (0) | 2017.10.15 |
[UE4] 폰트 (0) | 2017.09.26 |
[UE4] C++ 에셋, 오브젝트 레퍼런싱/객체생성 (1) | 2017.09.25 |
[UE4] CSV 파일 (0) | 2017.09.24 |
[UE4] unreal delegate (0) | 2017.09.24 |
[UE4] 마우스 입력 (0) | 2017.09.17 |