在 Unity 中进行本地存储,我们一般会用到 PlayerPrefs,而在 UE4 中,我们一般会使用 USaveGame,不过 USaveGame 在使用上和 PlayerPrefs 相差较大,这里给出一个...UE4 的 PlayerPrefs 实现,原理上仅是对 USaveGame 做了进一步的封装
首先我们继承 USaveGame 创建 UPlayerPrefsSaveGame 类型
#include...;
};
接着就是 PlayerPrefs 类型了,提供了和 Unity 中 PlayerPrefs 基本一致的接口
#include "CoreMinimal.h"
#include "PlayerPrefsSaveGame.h...PlayerPrefs 主动存储的实现方式,代码中除了释放 PlayerPrefs 时会做一次主动存储以外,另外还使用了一个脏标记(mPlayerPrefsDirty)来定时的检查是否要进行主动存储...是相通的,不同映射表之间不存在重复的表键(Key)