티스토리 뷰
반응형
언리얼에 블루프린트로 인자값을 받을수 있지만 c++에서 Implementation으로 이용하여 생성을 할때 블루프린트에서는 uint8, uint16 .... 값이 없기때문에 이점에서는 유의해야한다.
그래서 uint값을 받기 위해서는 오직 c++에서만 이용해야한다.
Interface.h
class SOULNETWORKPROJECT_API IMenuInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
UFUNCTION()
virtual void Join(uint32 Index) = 0; //상속의 방식으로 선언해줌
};
virtualclass.h
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "Blueprint/UserWidget.h"
#include "Public/Interface/MenuInterface.h" //Interface 헤더포함//
#include "SoulNetworkProjectGameInstance.generated.h"
UCLASS()
class SOULNETWORKPROJECT_API ProjectGameInstance : public UGameInstance, public IMenuInterface
{
GENERATED_BODY()
public:
UProjectGameInstance(const FObjectInitializer& ObjectInitializer);
virtual void Init();
//-------------------Interface Functions--------------------------//
UFUNCTION()
virtual void Join(uint32 Index) override; //이런식으로 재정의를 해줌//
////////////////////////////////////////////////////////////////////
};
virtualclass.cpp
//이런식으로 uint + n 값이 정상적으로 인식된다.//
void UProjectGameInstance::Join(uint32 Index)
{
if(!SessionInterface || !SessionSearch) return;
if(MainMenuWidget) MainMenuWidget->Teardown();
SessionInterface->JoinSession(0, SESSION_NAME,SessionSearch->SearchResults[Index]);
}
InterfaceCallingFunction
void UMainMenu::JoinServer()
{
//클래스인자값을 받아 InterfaceClass가 상속받았는지 유무를 파악하여 함수를 호출하는방법//
if (SelectedIndex.IsSet() && GetGameInstance()->GetClass()->ImplementsInterface(UMenuInterface::StaticClass()))
{
UE_LOG(LogTemp,Warning, TEXT("Selected index %d"), SelectedIndex.GetValue());
Cast<IMenuInterface>(GetGameInstance())->Join(SelectedIndex.GetValue());
}
//이런식으로 InterfaceClass 캐스팅하여 직접생성으로 함수를 호출하는방법//
IMenuInterface* Interface = Cast<IMenuInterface>(GetGameInstance())
if(SelectedIndex.IsSet() && Interface)
{
UE_LOG(LogTemp,Warning, TEXT("Selected index %d"), SelectedIndex.GetValue());
Interface->Join(SelectedIndex.GetValue());
}
}
위에 있는 호출방식은 c++에서만 호출이 가능함.
반응형
'Unreal Engine 4 프로그래밍 c++ > 기능' 카테고리의 다른 글
UE4 c++ Material 접근하기. (0) | 2023.07.06 |
---|---|
Unreal RecoilSystem c++ 적용하기. (CurveVector를 이용한 방법.) (0) | 2022.12.16 |
c++ UCurve+ (Vector, float, LinearColor) 사용하기. (3) | 2022.02.23 |
언리얼 interface c++ 호출방법 (0) | 2022.01.25 |
Unreal c++ SplineComponent사용하기 (0) | 2022.01.19 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 게임
- c++
- ActorComponent
- DirectX
- 언리얼엔진#FPS
- Multiplayer
- html5
- LockonSystem
- 언리얼#c++#Interface
- ros2
- directx3d
- 4.27
- UnReal
- Direct3D
- 언리얼#프로그래밍#c++#포트폴리오준비#블루프린트->c++전환
- 언리얼#c++#기능
- Replicated
- 언리얼#게임
- 1993
- ReplicatedUsing
- Multipalyer
- ubuntu
- ros
- 게임프로그래밍
- 시애틀의 잠 못 이루는 밤
- DirectX12
- Linux
- Direct12
- 언리얼
- 영화리뷰
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함