[Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ 2

2024. 3. 31. 21:50ยท โš™๏ธ ์—”์ง„/๐Ÿซ ์–ธ๋ฆฌ์–ผ

์˜ˆ์ œ

Person : Name(์ด๋ฆ„), Year(์—ฐ์ฐจ)

- Student : Id(ํ•™๋ฒˆ)

- Teacher : Id(์‚ฌ๋ฒˆ)

 

Person์—๋Š” DoLesson์ด๋ผ๋Š” ๊ฐ€์ƒ ํ•จ์ˆ˜๊ฐ€ ์žˆ์Œ

- Student์˜ DoLesson์€ ์ˆ˜์—…์„ ๋“ฃ๋Š” ํ–‰๋™

- Teacher์˜ DoLesson์€ ์ˆ˜์—…์„ ๊ฐ€๋ฅด์น˜๋Š” ํ–‰๋™


Object

ํ•ญ์ƒ ~.generated.h ํ—ค๋”๊ฐ€ ๋งˆ์ง€๋ง‰์— ์œ„์น˜ํ•ด์•ผ ํ•œ๋‹ค.

์›๋ž˜ ํ—ค๋”๊ฐ€ ๋งˆ์ง€๋ง‰

 

GameInstance

์›๋ž˜ ํ—ค๋”๊ฐ€ ํ•ญ์ƒ ์œ„์— ์œ„์น˜

 

 

GameInstance

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

#pragma once

#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "MyGameInstance.generated.h"

/**
 * 
 */
UCLASS()
class OBJECTREFLECTION_API UMyGameInstance : public UGameInstance
{
	GENERATED_BODY()
	
public:
	UMyGameInstance();

	virtual void Init() override;

private:
	UPROPERTY();
	FString SchoolName;
};
	UStudent* Student = NewObject<UStudent>(); // C++์˜ new์™€ ๋™์ผ
	UTeacher* Teacher = NewObject<UTeacher>();

	// get์œผ๋กœ ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ
	Student->SetName(TEXT("ํ•™์ƒ1"));
	UE_LOG(LogTemp, Log, TEXT("์ƒˆ๋กœ์šด ํ•™์ƒ ์ด๋ฆ„ : %s"), *Student->GetName());

	// reference๋กœ ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ
	FString CurrentTeacherName;
	FString NewTeacherName(TEXT("์ด๋“์šฐ"));
	FProperty* NameProp = UTeacher::StaticClass()->FindPropertyByName(TEXT("Name"));
	if (NameProp) {
		NameProp->GetValue_InContainer(Teacher, &CurrentTeacherName);
		UE_LOG(LogTemp, Log, TEXT("ํ˜„์žฌ ์„ ์ƒ๋‹˜ ์ด๋ฆ„ : % s"), *Teacher->GetName());

		// ์ด๋ฆ„ ๋ฐ”๊พธ๊ธฐ
		NameProp->SetValue_InContainer(Teacher, &NewTeacherName);
		UE_LOG(LogTemp, Log, TEXT("์ƒˆ๋กœ์šด ์„ ์ƒ๋‹˜ ์ด๋ฆ„ : % s"), *Teacher->GetName());
	}

	UE_LOG(LogTemp, Log, TEXT("==========================="));

	Student->DoLesson();
	UFunction* DoLessonFunc = Teacher->GetClass()->FindFunctionByName(TEXT("DoLesson"));
	if (DoLessonFunc) {
		Teacher->ProcessEvent(DoLessonFunc, nullptr);
	}

	UE_LOG(LogTemp, Log, TEXT("==========================="));

 

Person

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

#pragma once

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

/**
 * 
 */
UCLASS()
class OBJECTREFLECTION_API UPerson : public UObject
{
	GENERATED_BODY()
	
public:
	UPerson(); // ์ƒ์„ฑ์ž ์ฝ”๋“œ

	UFUNCTION()
	virtual void DoLesson();

	const FString& GetName() const; // get
	void SetName(const FString& InName); // set

protected:
	UPROPERTY() // ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ์— ๋“ฑ๋ก
	FString Name;

	UPROPERTY() // ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ์— ๋“ฑ๋ก
	int32 Year;

private:
	
};
// Fill out your copyright notice in the Description page of Project Settings.


#include "Person.h"

UPerson::UPerson()
{
	Name = TEXT("ํ™๊ธธ๋™");
	Year = 1;
}

void UPerson::DoLesson()
{
	UE_LOG(LogTemp, Log, TEXT("%s๋‹˜์ด ์ˆ˜์—…์— ์ฐธ์—ฌํ•ฉ๋‹ˆ๋‹ค."), *Name);
}

const FString& UPerson::GetName() const
{
	return Name;
}

void UPerson::SetName(const FString& InName)
{
	Name = InName;
}

 

Student

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

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Person.h"
#include "Student.generated.h"

/**
 * 
 */
UCLASS()
class OBJECTREFLECTION_API UStudent : public UPerson
{
	GENERATED_BODY()
	
public:
	UStudent(); // ์ƒ์„ฑ์ž

	virtual void DoLesson() override;

private:
	UPROPERTY()
	int32 Id;

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


#include "Student.h"

UStudent::UStudent()
{
	Name = TEXT("์ดํ•™์ƒ");
	Year = 1;
	Id = 1;
}

void UStudent::DoLesson()
{
	Super::DoLesson();

	UE_LOG(LogTemp, Log, TEXT("%dํ•™๋…„ %d๋ฒˆ %s๋‹˜์ด ์ˆ˜์—…์„ ๋“ฃ์Šต๋‹ˆ๋‹ค."), Year, Id, *Name);
}

 

Teacher

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

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Person.h"
#include "Teacher.generated.h"

/**
 * 
 */
UCLASS()
class OBJECTREFLECTION_API UTeacher : public UPerson
{
	GENERATED_BODY()
	
public:
	UTeacher();
	virtual void DoLesson() override;

private:
	UPROPERTY()
	int32 Id;
};
// Fill out your copyright notice in the Description page of Project Settings.


#include "Teacher.h"

UTeacher::UTeacher()
{
	Name = TEXT("์ด์„ ์ƒ");
	Year = 3;
	Id = 1;
}

void UTeacher::DoLesson()
{
	Super::DoLesson();
	UE_LOG(LogTemp, Log, TEXT("%d๋…„์ฐจ ์„ ์ƒ๋‹˜ %s๋‹˜์ด ์ˆ˜์—…์„ ๊ฐ•์˜ํ•ฉ๋‹ˆ๋‹ค."), Year, *Name);
}
์ €์ž‘์žํ‘œ์‹œ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'โš™๏ธ ์—”์ง„ > ๐Ÿซ ์–ธ๋ฆฌ์–ผ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Unreal] ํ€ต์…€ ๋ฉ”๊ฐ€์Šค์บ”  (1) 2024.05.01
[Unreal] ์‹œ์ž‘ํ•ด์š” ์–ธ๋ฆฌ์–ผ2022 ์ •๋ฆฌ  (1) 2024.05.01
[Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ (ensure, check)  (0) 2024.03.31
[Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ  (0) 2024.03.29
[Unreal] ์–ธ๋ฆฌ์–ผ C++ ๊ธฐ๋ณธ ํƒ€์ž…๊ณผ ๋ฌธ์ž์—ด ์ฒ˜๋ฆฌ  (0) 2024.03.28
'โš™๏ธ ์—”์ง„/๐Ÿซ ์–ธ๋ฆฌ์–ผ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • [Unreal] ํ€ต์…€ ๋ฉ”๊ฐ€์Šค์บ”
  • [Unreal] ์‹œ์ž‘ํ•ด์š” ์–ธ๋ฆฌ์–ผ2022 ์ •๋ฆฌ
  • [Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ (ensure, check)
  • [Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ
peewoong
peewoong
peewoong.logpeewoong ๋‹˜์˜ ๋ธ”๋กœ๊ทธ์ž…๋‹ˆ๋‹ค.
peewoong
peewoong.log
peewoong
์ „์ฒด
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ
    • ๐Ÿ™‚ Info
    • ๐ŸŽฎ ๊ฒŒ์ž„ ๊ด€๋ จ ๊ฐœ๋…
    • ๐Ÿ‘ฉโ€๐Ÿ’ป ํ”„๋กœ๊ทธ๋ž˜๋ฐ
      • ๐ŸŽญ C
      • ๐ŸŽ  C++
      • ๐Ÿ• C#
      • โœจ ์ž๋ฃŒ๊ตฌ์กฐ
      • ๐ŸŽ ์•Œ๊ณ ๋ฆฌ์ฆ˜
      • ๐Ÿ”ข ์ˆ˜ํ•™
      • ๐ŸŽจ ๊ทธ๋ž˜ํ”ฝ์Šค
    • โš™๏ธ ์—”์ง„
      • ๐Ÿง€ VS
      • ๐Ÿค ์œ ๋‹ˆํ‹ฐ
      • ๐Ÿซ ์–ธ๋ฆฌ์–ผ
      • ๐Ÿน DirectX
      • ๐Ÿฆฅ error
    • ๐Ÿ“ฝ๏ธ ํ”„๋กœ์ ํŠธ
    • ๐Ÿง ์ฝ”๋”ฉํ…Œ์ŠคํŠธ

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

hELLO ยท Designed By ์ •์ƒ์šฐ.v4.2.0
peewoong
[Unreal] ์–ธ๋ฆฌ์–ผ ์˜ค๋ธŒ์ ํŠธ ๋ฆฌํ”Œ๋ ‰์…˜ ์‹œ์Šคํ…œ 2
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”

๋‹จ์ถ•ํ‚ค

๋‚ด ๋ธ”๋กœ๊ทธ

๋‚ด ๋ธ”๋กœ๊ทธ - ๊ด€๋ฆฌ์ž ํ™ˆ ์ „ํ™˜
Q
Q
์ƒˆ ๊ธ€ ์“ฐ๊ธฐ
W
W

๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๊ธ€

๊ธ€ ์ˆ˜์ • (๊ถŒํ•œ ์žˆ๋Š” ๊ฒฝ์šฐ)
E
E
๋Œ“๊ธ€ ์˜์—ญ์œผ๋กœ ์ด๋™
C
C

๋ชจ๋“  ์˜์—ญ

์ด ํŽ˜์ด์ง€์˜ URL ๋ณต์‚ฌ
S
S
๋งจ ์œ„๋กœ ์ด๋™
T
T
ํ‹ฐ์Šคํ† ๋ฆฌ ํ™ˆ ์ด๋™
H
H
๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด
Shift + /
โ‡ง + /

* ๋‹จ์ถ•ํ‚ค๋Š” ํ•œ๊ธ€/์˜๋ฌธ ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด์šฉ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธฐ๋ณธ ๋„๋ฉ”์ธ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.