언리얼의 모듈이 저장된 장소
C:\Program Files\Epic Games\UE_4.26\Engine\Source\Runtime
언리얼의 기능을 사용하고자 할때 헤더파일을 include 해야 합니다.
위에 폴더명 중에 사용하고자 하는 것이 있으면
프로젝트명.Build.cs 파일을 열고, PublicDependencyModuleNames에 추가(add) 해야 합니다.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Sockets.h"
#include "SocketSubsystem.h"
#include "IPAddress.h"
#include "CoreGlobals.h"
#include "ASync/Async.h"
#include "Test_Network.generated.h"
UCLASS()
class CPPTEST_API ATest_Network : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ATest_Network();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
UFUNCTION(BlueprintCallable, Category = "Test_Network")
FString GetIpAddress();
};
추가한 폴더명 안의 헤더파일을 include 하면 에러없이 잘 빌드 됩니다.
#include "Test_Network.h"
// Sets default values
ATest_Network::ATest_Network()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
// Called when the game starts or when spawned
void ATest_Network::BeginPlay()
{
Super::BeginPlay();
}
FString ATest_Network::GetIpAddress()
{
FString IpAddr("NONE");
bool canBind = false;
TSharedRef<FInternetAddr> LocalIp = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, canBind);
if (LocalIp->IsValid())
{
IpAddr = LocalIp->ToString(false);
}
return IpAddr;
}
저는 Socket을 참조하여 내 컴퓨터 IP를 가져오는 테스트를 해봤습니다.
'Unreal' 카테고리의 다른 글
UE4 이벤트 쉽게 사용하기 (1) | 2021.04.22 |
---|---|
UE4 C++ WebSocket 과 Event 사용하기 (0) | 2021.04.22 |
[Unreal] Log 사용하기 (PrintString) (0) | 2021.02.17 |
[Unreal] UPROPERTY, UFUNCTION (BlueprintNativeEvent) (0) | 2021.02.17 |
[UE4] Sound 포커스를 잃지 않게 하기 (0) | 2021.02.01 |