언리얼 엔진 Slate, UMG

Woogle·2023년 11월 27일
0

언리얼 엔진 5

목록 보기
48/59

📄 슬레이트 (Slate)

  • 언리얼 엔진의 커스텀 UI 프로그래밍 프레임워크

  • 언리얼 엔진의 에디터 인터페이스는 Slate로 만들어져있다.

    • Contents Browser, Blueprint Editor, Animation Editor, Material Editor 등
  • C++ 코드로 컨트롤 할 수 있다는 장점이 있으며, Prefix는 'S'다.

    • SWidget, SPanel 등
  • Slate UI 프레임워크를 사용하기 위해서는 *.build.cs 파일에 관련 모듈을 추가해주어야한다.

🚀 Slate 관련 모듈 종속성 세팅

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

📄 UMG (Unreal Motion Graphic)

  • 언리얼 엔진의 비주얼 UI 제작 툴

  • 미리 만들어진 Widget들을 조립해서 인게임 UI를 편리하게 만들 수 있다.

    • UButton, UTextBlock, UProgressBar 등
  • 사실 UMG도 내부적으로 코드를 뜯어보면 Slate로 구성되어있다.

🚀 UButton의 내부 코드

TSharedRef<SWidget> UButton::RebuildWidget()
{
	MyButton = SNew(SButton)
		.OnClicked(BIND_UOBJECT_DELEGATE(FOnClicked, SlateHandleClicked))
		.OnPressed(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandlePressed))
		.OnReleased(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandleReleased))
		.OnHovered_UObject( this, &ThisClass::SlateHandleHovered )
		.OnUnhovered_UObject( this, &ThisClass::SlateHandleUnhovered )
		.ButtonStyle(&WidgetStyle)
		.ClickMethod(ClickMethod)
		.TouchMethod(TouchMethod)
		.PressMethod(PressMethod)
		.IsFocusable(IsFocusable)
		;

	if ( GetChildrenCount() > 0 )
	{
		Cast<UButtonSlot>(GetContentSlot())->BuildSlot(MyButton.ToSharedRef());
	}
	
	return MyButton.ToSharedRef();
}

📄 참고자료

profile
노력하는 게임 개발자

0개의 댓글