- Home /
The name "Game Foundation" does not exist in the current context
Hi! I'm trying out Game Foundation and I want to save all the changes that are made in Runtime. So I found this code in the official tutorial:
using UnityEngine;
using UnityEngine.GameFoundation;
public class SaveGame : MonoBehaviour
{
IDataPersistence localPersistence;
void Awake()
{
// choose what format you want to use
JsonDataSerializer dataSerializer = new JsonDataSerializer();
// choose where and how the data is stored
localPersistence = new LocalPersistence(dataSerializer);
// tell Game Foundation to initialize using this
// persistence system. Only call Initialize once per session.
GameFoundation.Initialize(localPersistence);
}
public void Save()
{
GameFoundation.Save(localPersistence);
}
public void Load()
{
GameFoundation.Load(localPersistence);
}
}
But I'm having this problem:
Any help will be appreciated!
Can you replace GameFoundation
by UnityEngine.GameFoundation
in your methods?
Does the package contain an asmdef file? (look for it in Library\PackageCache
)
Hmm... I replaced it and it says:
The type or namespace name 'Initialize' does not exist in the namespace 'UnityEngine.GameFoundation' (are you missing an assembly reference?)
And the package has a lot of asmdef files including "Unity.GameFoundation.asmdef".
$$anonymous$$y bad, it should be UnityEngine.GameFoundation.GameFoundation
instead.
If there is an asmdef, you may need to create an asmdef for your project and reference GameFoundation's asmdef in your project's asmdef.
Answer by sacredgeometry · Dec 10, 2020 at 04:54 AM
GameFoundation isn't a namespace in the normal unity assemblies its a preview package you need to install.
Have you installed it?
Your answer
Follow this Question
Related Questions
Loading data from a txt file - C# 3 Answers
Save/Load Game and buttons New Game/Load Game? 1 Answer
What are the basics of saving and loading game? 1 Answer
Only able to save inside the editor problem 2 Answers
How to make a save and load option 2 Answers