ES3File Class
Description
Represents a file in memory which can by synced with a file in storage.
Because the ES3File keeps the file in memory and only commits changes to storage when the Sync method is called, it provides improved performance over the ES3.Save and ES3.Load methods which store data immediately to storage.
Constructors
ES3File Constructor | Creates an ES3File. |
Save and Load Methods
ES3File.Save | Saves a value to the ES3File. |
ES3File.Load | Loads a value from the ES3File. |
ES3File.LoadInto | Loads a value from an ES3File into an existing object. |
ES3File.Sync | Synchronises the data in this ES3File with the file in storage. |
ES3File.LoadRawBytes | Loads the contents of the ES3File as a byte array. |
ES3File.LoadRawString | Loads the contents of the ES3File as a string. |
Other Methods
ES3File.DeleteKey | Deletes a key from the ES3File. |
ES3File.KeyExists | Checks whether a key exists in the ES3File. |
ES3File.Clear | Removes the data stored in this ES3File. The ES3File will be empty after calling this method. |
ES3File.GetKeys | Returns an array of all of the key names in this ES3File. |
ES3File.Size | Returns the size of the data stored in this ES3File in bytes. |
Examples
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Create a new ES3File from a file in storage. var es3File = new ES3File("myFile.es3"); // Load some keys from the ES3File. myInt = es3File.Load<int>("myInt"); myString = es3File.Load<string>("myString"); // Save some keys to the ES3File. es3File.Save<Vector3>("myPosition", transform.position); es3File.Save<Quaternion>("myRotation", transform.rotation); // Delete some key from the ES3File. es3File.DeleteKey("myInt"); es3File.DeleteKey("myString"); // Sync the file so the file in storage is the same as our ES3File. es3File.Sync(); |
JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Create a new ES3File from a file in storage. var es3File = new ES3File("myFile.es3"); // Load some keys from the ES3File. myInt = es3File.Load.<int>("myInt"); myString = es3File.Load.<string>("myString"); // Save some keys to the ES3File. es3File.Save.<Vector3>("myPosition", transform.position); es3File.Save.<Quaternion>("myRotation", transform.rotation); // Delete some key from the ES3File. es3File.DeleteKey("myInt"); es3File.DeleteKey("myString"); // Sync the file so the file in storage is the same as our ES3File. es3File.Sync(); |