C++蓝图
UGameInstance 是 Unreal Engine 提供的一个核心类,它本身继承自 UObject。作为游戏的全局管理者,UGameInstance 在游戏启动时创建,在退出时才销毁,它的生命周期贯穿整个游戏运行过程,即使切换关卡也不会被重置。因此,它非常适合用来存放需要跨关卡共享的数据或管理类,例如玩家数据、网络会话管理、全局事件广播
ue蓝图找不到定义的函数
- 仅仅在 .cpp 文件中实现函数是不够的,必须在头文件中声明,并加上 UFUNCTION 宏才能被蓝图识别
- 项目设置 gameinstance 要设置为自定义的
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "HelloGameInstance.generated.h"
/**
*
*/
UCLASS()
class HELLOWORLD_API UHelloGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UHelloGameInstance();
public:
UFUNCTION(BlueprintCallable, meta = (ToolTip = "开启与服务器的连接"))
bool InitHello(FString Host, FString Port);
};
插件
在xx.uproject 中定义