UE - UObject

Ryan Ham·2024년 6월 6일
1

Unreal Engine

목록 보기
4/27

언리얼 엔진 시스템
- 접두사 F : C++ Object
- 접두사 U : Unreal Object

// Unreal Object cpp 예시

#pragma once
// Unreal Object가 되기 위해서 기본적으로 포함할 2가지 header file은 CoreMinimal, UObject/NoExportTypes
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
// generated.h는 Intermediate에 존재하는 특수한 파일, VS에서 Build를 하면 자동으로 생성된다. 
// 
#include "MyObject.generated.h"

/**
 * 
 */
// Unreal Object임을 알리는 UCLASS 매크로
UCLASS()
// ~~_API가 붙는 이유
class INFLEARN_TEST_API UMyObject : public UObject
{
	GENERATED_BODY()
	
};

generated.h는 뭘까?

Unreal Object에 이 코드를 분석하는 단계가 한 가지가 있어가지고 바로 컴파일되는 것이 아니고,UHT(Unreal Header Tool)에 의해서 소스 코드를 자동으로 생성하고, 자동으로 생성된 코드를 포함해서 마지막 최종 build를 진행하는 두 단계의 과정으로 진행된다고 이해하자.

따라서, 개발자는 단순히 지정된 매크로만 입력해주면 되고, UHT가 자동으로 생성하는 header file에는 접근할 필요가 없다.

이 UHT에 의해 자동으로 생성되는 header file이 ~generated.h 파일이고 이는 intermediate 폴더 깊숙한 곳에 저장된다.


UObject가 가지고 있는 특성들

* Object Lifecycle Management

    Construction and Destruction: UObject handles object creation and destruction, providing constructors and destructors.

    Garbage Collection: UObject participates in Unreal Engine's garbage collection system, ensuring that unused objects are properly cleaned up to free memory.

* Reflection System:

    Metadata and Reflection: UObject provides support for the Unreal Engine reflection system, allowing for runtime type information, property introspection, and dynamic function calls.

    UCLASS, UPROPERTY, UFUNCTION: Macros that expose class members and methods to the Unreal Engine reflection system, enabling them to be used in Blueprints, serialization, and other engine systems.

* Serialization:

    Automatic Serialization: UObject provides built-in support for saving and loading object properties to and from disk, making it easier to implement save/load functionality.

* Networking:

    Replication: UObject supports property replication, which is essential for multiplayer games to synchronize object state across networked clients and servers.

    RPC (Remote Procedure Calls): UObject allows functions to be called across the network, enabling client-server communication.

* Event System:

    Delegates and Events: UObject supports Unreal's event system, allowing objects to broadcast and listen for events. This is useful for creating responsive and interactive game logic.

* Object Identification and Naming:

    Unique Names: Every UObject has a unique name within its context, which can be used for identification and lookup.

    Path Names: UObject can be identified and referenced by their full path names in the object hierarchy.

* Transient and Editor-Only Properties:

    Transient Properties: Properties that are marked as transient are not saved to disk and are only valid for the current session.

    Editor-Only Properties: Properties that are used only within the editor environment and are not included in the packaged game.

* Blueprint Integration:

    BlueprintCallable and BlueprintImplementableEvent: Macros that expose C++ functions and events to Blueprints, enabling a mix of C++ and Blueprint scripting.

profile
🏦KAIST EE | 🏦SNU AI(빅데이터 핀테크 전문가 과정) | 📙CryptoHipsters 저자

0개의 댓글