class UObject
{
public:
// 공유 가능한 오브젝트 (얕은 복사)
UObject* ObjectA;
UObject* ObjectB;
// 공유 불가능한 서브 오브젝트 (깊은 복사 필요)
UObject* SubObjectA;
UObject* SubObjectB;
virtual ~UObject() {}
// 서브 오브젝트를 복제하는 함수 (하위 클래스에서 재정의 가능)
virtual void DuplicateSubObjects()
{
if (SubObjectA)
SubObjectA = SubObjectA->Duplicate();
if (SubObjectB)
SubObjectB = SubObjectB->Duplicate();
}
// 현재 오브젝트를 복제하는 함수
virtual UObject* Duplicate()
{
// 새 객체 생성
UObject* NewObject = new UObject(*this); // 얕은 복사 수행
// 서브 오브젝트는 깊은 복사로 별도 처리
NewObject->DuplicateSubObjects();
return NewObject;
}
};
class UEditorEngine : public UObject
{
TArray<FWorldContext> WorldContexts;
virtual void Tick(float DeltaSeconds);
};
void UEditorEngine::Tick(float DeltaSeconds)
{
// Editor 전용 액터 Tick 처리
for (FWorldContext& WorldContext : WorldContexts)
{
UWorld* EditorWorld = WorldContext.World();
if (EditorWorld && EditorWorld->WorldType == EWorldType::Editor)
{
ULevel* Level = EditorWorld->Level;
{
for (AActor* Actor : Level->Actors)
{
if (Actor && Actor->bTickInEditor)
{
Actor->Tick(DeltaSeconds);
}
}
}
}
else if (EditorWorld && EditorWorld->WorldType == EWorldType::PIE)
{
ULevel* Level = EditorWorld->Level;
{
for (AActor* Actor : Level->Actors)
{
if (Actor)
{
Actor->Tick(DeltaSeconds);
}
}
}
}
}
}
void StartPIE()
{
UWorld* EditorWorld = GEditor->GetEditorWorldContext().World();
UWorld* PIEWorld = UWorld::DuplicateWorldForPIE(EditorWorld, ...);
GWorld = PIEWorld;
// AActor::BeginPlay()
PIEWorld->InitializeActorsForPlay();
}
void EndPIE()
{
if (GWorld && GWorld->IsPIEWorld())
{
GWorld->CleanupWorld();
delete GWorld;
}
GWorld = GEditor->GetEditorWorldContext().World();
}
월드에 Actor를 배치하고 다양한 Component를 추가하세요.
TextRenderComponent 클래스를 구현하세요.
기존 UUID 텍스트 렌더링 로직을 Component 클래스화 한다. UE에 TextRenderComponent를 참고하세요.
BillboardComponent 클래스를 구현하세요.
UE에 BillboardComponent를 참고하세요.
맴버 변수 Sprite에 Drop List UI를 통해 선택한 UTexture를 Assign 한다.
UE엔진에서 아래 이미지들을 가져와 Editor\Icon 폴더에 복사 합니다.
SpotLight_64x.png, PointLight_64x.png, Pawn_64x.png
UWorld 클래스를 구현하세요.
enumEWorldType
{
Editor,
EditorPreview,
PIE,
Game,
};
classUWorld :public UObject
{
// GTL에서는 Sub Level은 고려하지 않습니다.
ULevel* Level;
EWorldType WorldType;
voidTick(float DeltaTime)
{
for (AActor* Actor : Level->Actors)
{
if (Actor && Actor->IsActorTickEnabled())
{
Actor->Tick(DeltaTime);
}
}
}
};
ULevel 클래스를 구현하세요.
classULevel :public UObject
{
TArray<AActor*> Actors;
};
AActor 클래스를 구현하세요.
classAActor :public UObject
{
TSet<UActorComponent*> OwnedComponents;
USceneComponent* RootComponent;
bool bTickInEditor;
virtual voidBeginPlay();
virtual voidEndPlay(const EEndPlayReason::Type EndPlayReason);
virtual voidTick(float DeltaTime)
{
// 소유한 모든 컴포넌트의 Tick 처리
for (UActorComponent* Component : OwnedComponents)
{
if (Component && Component->IsComponentTickEnabled())
{
Component->TickComponent(DeltaTime, ...);
}
}
}
};