- Home /
Question by
Kinetrator · Aug 01, 2021 at 04:30 PM ·
referencestatic
How to reference an object from a static class?
Hello, I have a static class Metadata, where I store the main parameters. In a SaveLoad class I try to write all the metadata fields to a file. The question is if I can do it w/o creating any intermediate parameters, just reference already existed object as a whole. I know can reference independent variables inside my static class, like Metadata.field1, one by one, but I believe it's not an optimum solution. Thank you!
public static void SaveMetadataToFile() {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create (Application.persistentDataPath + "/savedMetadata.gd");
bf.Serialize(file, Metadata.**????**);
file.Close();
Debug.Log("Game has been saved");
}
Comment
Your answer
