Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// .h
- UCLASS()
- class UMyGameInstance : public UGameInstance
- {
- GENERATED_BODY()
- static TWeakObjectPtr<UMyGameInstance> Instance;
- public:
- static UMyGameInstance* Get() { return Instance.Get(); }
- UFUNCTION(BlueprintPure, Category="Game")
- static UMyGameInstance* GetMyGameInstance() { return Get(); }
- virtual void Init() override;
- virtual void Shutdown() override;
- private:
- };
- /// .cpp
- TWeakObjectPtr<UMyGameInstance> UMyGameInstance::Instance;
- void UMyGameInstance::Init()
- {
- Instance = this;
- Super::Init();
- }
- void UMyGameInstance::Shutdown()
- {
- Super::Shutdown();
- Instance.Reset();
- }
Advertisement
Add Comment
Please, Sign In to add comment