继承关卡基类 ALevelScriptActor 去扩展,蓝图继承自己的自定义关卡类
MyLevel.h
#pragma once #include "MyLevel.generated.h" UCLASS() class AMyLevel : public ALevelScriptActor { GENERATED_BODY() public: AMyLevel(); virtual ~AMyLevel(); virtual void BeginPlay() override; virtual void Destroyed() override; public: UFUNCTION(BlueprintCallable, Category = "AMyLevel") FString GetLevelName() { return LevelName; } public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AMyLevel") FString LevelName; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AMyLevel") int32 LevelCounter; };
MyLevel.cpp
#include "MySkeleton.h" #include "MyLevel.h" AMyLevel::AMyLevel() : Super() { LevelName = "AMyLevel"; LevelCounter = 123; } AMyLevel::~AMyLevel() { UE_LOG(LogMySkeleton, Warning, TEXT("--- AMyLevel::~AMyLevel")); } void AMyLevel::BeginPlay() { UE_LOG(LogMySkeleton, Warning, TEXT("--- AMyLevel::BeginPlay")); } void AMyLevel::Destroyed() { UE_LOG(LogMySkeleton, Warning, TEXT("--- AMyLevel::Destroyed")); }
关卡蓝图中继承这个 自定义关卡类
修改父类
显示父类的变量
相关api
调用关卡中的事件
virtual bool RemoteEvent(FName EventName);
从源码中可以看出,它是重当前 World 中的 所有Level 中查找 显示状态中的 且 事件参数为零的 事件,并执行它。
for( TArray<ULevel*>::TConstIterator it = GetWorld()->GetLevels().CreateConstIterator(); it; ++it ) if( CurLevel && CurLevel->bIsVisible ) if( EventTarget && EventTarget->NumParms == 0)
参考资料
作者:yangxuan0261 发表于2017/1/20 14:09:57 原文链接
阅读:15 评论:0 查看评论