UE4 如何在非UE4类 获取到GameInstance

UCLASS()
class FLIGHTSIMULATOR_API UFLYGameInstance : public UGameInstance
{
	GENERATED_BODY()
	
public:
	UFLYGameInstance();

	virtual void StartGameInstance() override;

	virtual void Shutdown() override;

	virtual void Init() override;

protected:

};
extern FLIGHTSIMULATOR_API class UFLYGameInstance* GGameInstance;
FLIGHTSIMULATOR_API UFLYGameInstance* GGameInstance = nullptr;

UFLYGameInstance::UFLYGameInstance()
{
	GGameInstance = this;
}

给暴露出去并赋值

UGameplayStatics::GetAllActorsOfClass(GGameInstance->world, AMyActor::StaticClass(), outputAc);

其他类就直接拿到用了

猜你喜欢

转载自blog.csdn.net/qqQQqsadfj/article/details/131772265
UE4