Files
UnrealLuaDemo/Source/UnrealLuaDemo/Core/LuaGameInstance.h
T

36 lines
879 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Containers/Ticker.h"
#include "Engine/GameInstance.h"
#include "LuaGameInstance.generated.h"
class UWorld;
/**
* C++ 薄桥接 GameInstance:通过回调转发生命周期(OnInit / OnTick / OnWorldCleanup / OnShutdown)
* 至纯 TS/Lua 入口模块 `main`。
*/
UCLASS()
class UNREALLUADEMO_API ULuaGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
virtual void Init() override;
virtual void Shutdown() override;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Lua")
FString LuaModuleName = TEXT("main");
private:
bool HandleCoreTick(float DeltaSeconds);
void HandleWorldCleanup(UWorld* World, bool bSessionEnded, bool bCleanupResources);
FTSTicker::FDelegateHandle CoreTickHandle;
FDelegateHandle WorldCleanupHandle;
};