Unreal

언리얼 매크로 함수들 이해하기 - UPROPERTY() && UFUNCTION() && UCLASS()

TIM_0529 2023. 1. 1. 18:32
반응형

UPROPERTY() - 에디터나 블루프린터상에 변수를 노출시키고 싶을 때 사용한다.

 

UFUNCTION() -  블루프린터에서 함수를 불러올 수 있게 한다.

 

UCLASS(Blueprintable) - 클래스 액터를 참조하는 블루프린트를 만드는 것을 가능하게 해준다.

 

ex)

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "MyObject.generated.h"

/**
 * 
 */
UCLASS(Blueprintable)
class MINIMAL_DEFAULT_API UMyObject : public UObject
{
	GENERATED_BODY()

public:
	UMyObject();

	UPROPERTY(BlueprintReadOnly , Category = "MyVariables") // reflection system 에 노출시킨다.
	float MyFloat;

	UFUNCTION(BlueprintCallable, Category = "MyFunctions")	// 블루 프린트에서 더 쉽게 찾을 수 있다.
	void MyFunction();
};

UCLASS(Blueprintable) 를 사용해서 블루프린트로 만드는 것을 가능하게 해 준다.

 

UPROPERTY(BlueprintReadOnly , Category = "MyVariables")

블루 프린트에서 읽기만 가능한 변수 라는 것을 알려주고 다음에 카테고리를 사용해서 찾을 수 있다.

UFUNCTION(BlueprintCallable, Category = "MyFunctions")

위와 같은 역할을 한다.

 

UPROPERTY() 에는 더욱 다양한 조건을 줄 수 있다.

	UPROPERTY(VisibleAnywhere, Category = "ActorMeshComponents")
	UStaticMeshComponent* StaticMesh;

	// Location used by SetActorLocation() when beginPlay() is called
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Category = "FloaterVectors")
	FVector InitialLocation;

	// Location of the Actor when dragged in fromm the editor
	UPROPERTY(VisibleInstanceOnly,BlueprintReadWrite, Category = "FloaterVectors")
	FVector PlacedLocation;

	UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Floater Variables")
	bool bInitializeFloaterLocations;

VisibleAnywhere - 에디터와 블루 프린트 모두 볼수있다.

 

EditInstanceOnly - 프로퍼티 창에서 편집할 수 있다.

VisibleInstanceOnly - 프로퍼티 창에서 편집 불가.

EditDefaultsOnly - 프로퍼티 창에서 편집이 가능합니다.

반응형