Files
UnrealEngineUWP/Engine/Documentation/Source/Programming/QuickStart/3/QuickStart_3.KOR.udn
Sungjin Hong 14aa86490f #loc UE4DocKOR
[CL 2698758 by Sungjin Hong in Main branch]
2015-09-21 06:53:18 -04:00

182 lines
5.8 KiB
Plaintext

INTSourceChangelist:2650085
Availability: Public
Title:3 - C++ 코드 작성 및 컴파일
Crumbs:%ROOT%, Programming, Programming/QuickStart
Description:C++ 클래스를 작성하고 언리얼 엔진으로 컴파일합니다.
SkillLevel: Beginner
Version: 4.8
[VAR:Steps]
[OBJECT:Navigation]
[PARAM:previous]
[예전 단계](Programming\QuickStart\2 "%Programming\QuickStart\2:title%")
[/PARAM]
[PARAM:current]
[/PARAM]
[PARAM:home]
[퀵스타트 홈](Programming\QuickStart)
[/PARAM]
[PARAM:next]
[다음 단계](Programming\QuickStart\4 "%Programming\QuickStart\4:title%")
[/PARAM]
[/OBJECT]
[/VAR]
%Steps%
1. **Visual Studio** 에서 **Solution Explorer** 패널을 사용하여 새로 만든 C++ 파일을 찾아보겠습니다. 우리 예제에서는 이름이 `FloatingActor.cpp`, `FloatingActor.h` 식으로 되어있으며, "QuickStart" 프로젝트 안에 있을 것입니다.
[![](SolutionExplorer_Files.png)](SolutionExplorer_Files.png)
[REGION:note]이제 코드를 작성하려는 시점입니다. 이 페이지 하단에서 종료 시점 상태의 사용된 모든 코드를 찾아보실 수 있습니다.[/REGION]
1. `FloatingActor.h` 에서 닫힌 괄호와 파일 끝의 세미콜론 바로 앞에 다음 코드를 추가하겠습니다:
float RunningTime;
1. `FloatingActor.cpp` 로 전환하여, **AFloatingActor::Tick** 끝의 닫힌 괄호 직전에 다음 코드를 추가합니다:
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f; //높이에 20 을 곱합니다
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
[REGION:tip] 방금 작성한 코드는 **FloatingActor** 가 위아래로 부드럽게 나타났다 사라지도록 만드는데, 시간에 따른 운동 기록을 추적하기 위해 만든 _RunningTime_ 변수를 사용한 것입니다. [/REGION]
%Globals:OSSelect%
[OBJECT:ToggleButtonContent]
[PARAMLITERAL:category]
OS
[/PARAMLITERAL]
[PARAMLITERAL:id]
windows
[/PARAMLITERAL]
[PARAMLITERAL:active]
active_button_content
[/PARAMLITERAL]
[PARAM:content]
* 코딩이 완료되었으니, **Solution Browser** 의 프로젝트에 우클릭 후 **Build** 명령을 선택하거나, **언리얼 에디터** 의 **컴파일** 버튼을 누르면 컴파일 가능합니다. 컴파일이 성공하면 **언리얼 에디터** 가 자동으로 변경사항을 로드합니다.
[![](CompileFromVS.png)](CompileFromVS.png)
_Visual Studio 에서 컴파일하는 모습_
[![](CompileFromEditor.png)](CompileFromEditor.png)
_언리얼 에디터에서 컴파일하는 모습_
[/PARAM]
[/OBJECT]
[OBJECT:ToggleButtonContent]
[PARAMLITERAL:category]
OS
[/PARAMLITERAL]
[PARAMLITERAL:id]
mac
[/PARAMLITERAL]
[PARAMLITERAL:active]
active_button_content
[/PARAMLITERAL]
[PARAM:content]
[REGION:tip]
Xcode 에서 빌드할 때는 게임 프로젝트만 컴파일하는 것이지, 에디터는 아닙니다.
[/REGION]
* 코딩이 완료되었으니 XCode 의 Debug Configuration 을 사용하여 컴파일해 주면 됩니다. **Product > Build** 옵션입니다.
![](ProjectBuild_mac.png)
_XCode 의 Debug Configuration 을 사용하여 컴파일하는 모습_
* XCode 의 Development Configuration 을 사용해서도 컴파일 가능합니다. **Product > Build For > Profiling** 옵션입니다.
![](ProjectBuildProfile_mac.png)
_XCode 의 Development Configuration 을 사용하여 컴파일하는 모습_
[![](CompileFromEditor.png)](CompileFromEditor.png)
_**언리얼 에디터** 에서 컴파일하는 모습_
[REGION:note]
바이너리 에디터를 실행할 때, **Uncooked** 환경ㅅ헐정으로 프로젝트를 리빌드한 경우 -game 플래그를, **Debug** 환경설정으로 프로젝트를 리빌드한 경우 -debug 플래그를 붙여주는 것이 중요합니다.
[/REGION]
[/PARAM]
[/OBJECT]
이제 코드를 기반으로 **언리얼 에디터** 에 오브젝트를 만들 준비가 되었습니다! 참고로, 이 글에 사용된 모든 코드는 아래 포함되어 있습니다.
[OBJECT:Section]
[PARAMLITERAL:id]
code
[/PARAMLITERAL]
[PARAM:heading]
완성된 코드
[/PARAM]
[PARAM:content]
**FloatingActor.h**
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"
UCLASS()
class QUICKSTART_API AFloatingActor : public AActor
{
GENERATED_BODY()
public:
// 이 액터 프로퍼티의 기본값을 설정합니다
AFloatingActor();
// 게임 시작시 또는 스폰시 호출됩니다
virtual void BeginPlay() override;
// 모든 프레임마다 호출됩니다
virtual void Tick( float DeltaSeconds ) override;
float RunningTime;
};
**FloatingActor.cpp**
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "QuickStart.h"
#include "FloatingActor.h"
// 기본값을 설정합니다
AFloatingActor::AFloatingActor()
{
// 이 액터가 모든 프레임마다 Tick() 호출하도록 설정합니다. 필요치 않은 경우 꺼주면 퍼포먼스가 향상됩니다
PrimaryActorTick.bCanEverTick = true;
}
// 게임 시작시 또는 스폰시 호출됩니다
void AFloatingActor::BeginPlay()
{
Super::BeginPlay();
}
// 모든 프레임마다 호출됩니다
void AFloatingActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f; //높이에 20 을 곱합니다
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
}
[/PARAM]
[/OBJECT]
%Steps%