1. 创建和设置
创建继承自 GameInstance 的C++类

头文件里加上
UCLASS(BlueprintType, Blueprintable)
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "MyGameInstance.generated.h"
/**
*
*/
UCLASS(BlueprintType, Blueprintable)
class EXERCISE_API UMyGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float health = 10.0f;
};

本文介绍了如何在UE4中创建并设置GameInstance的C++类,包括继承GameInstance、配置Project Settings以及在蓝图中使用GameInstance的方法,同时提及了如何处理多个单例的情况。
最低0.47元/天 解锁文章
1313

被折叠的 条评论
为什么被折叠?



