Skip to main content

SerializedSavedDynamicObject

A class in Root.Township, the global namespace.

A saved object (prefab hash plus its serialized state) in a form Unity can serialize, with the chunk versioning it was saved under. Used for postboxes, set pieces and spawn strings.

Constructors​

MemberWhat it is
SerializedSavedDynamicObject(List<uint[]> savingData, uint sizeBytes, uint prefabHash, ChunkVersioning chunkVersioning = null)Creates a SerializedSavedDynamicObject from savingData, sizeBytes, prefabHash and chunkVersioning.

Fields​

4 private and internal fields
MemberWhat it is
private bool isInitializedTrue once the serialized arrays have been unpacked into data and Versioning. Not serialized.
private static Logger loggerNLog logger for this class.
private uint[] serializedDataThe saved entity's bytes packed as uint words, so Unity can serialize them.
private uint[] versioningThe chunk versioning array the data was saved with; Initialize rebuilds Versioning from it.

Properties​

MemberWhat it is
ChunkVersioning Versioning { get; private set; }The chunk versioning the data was saved under. Defaults to the latest.

Methods​

MemberWhat it is
static SerializedSavedDynamicObject GetFromString(string value)Parses a spawn string: comma separated numbers (prefab hash, byte size, data) with optional versioning after a |.
static SerializedSavedDynamicObject GetSaveOf(NetworkPrefab prefab)Saves a prefab's current state under the latest versioning.
override ChunkVersioning GetVersion()The chunk versioning the data was saved under.
void Initialize()Rebuilds the working data and versioning after Unity deserialization. Safe to call more than once.
NetworkEntity Load(Transform parent, Vector3 localPosition, Quaternion localRotation, Chunk chunk, SaveMode saveMode)Obsolete: spawns the object and loads into it, but spawns network entities twice. Use LoadInto.
void LoadInto(NetworkEntity existing, SaveMode saveMode)Server: loads the saved state into an existing entity, initializes it and sets its save mode.
void LoadIntoPrefablessEntity(NetworkEntity entity)Loads saved state into an entity that has no prefab, such as a scene object.
static SerializedSavedDynamicObject SaveFromPrefablessEntity(NetworkEntity entity)Saves an entity that has no prefab, with a prefab hash of 0.
static NetworkEntity SpawnFromString(string value, SaveMode saveMode)Spawns an object from a spawn string. Returns null and logs on failure. Used by spawn string and trade commands.
2 private and internal methods
MemberWhat it is
private void Load(NetworkEntity existing, Transform parent, Vector3 localPosition, Quaternion localRotation, SaveMode saveMode)Obsolete: spawns the object and loads into it, but spawns network entities twice. Use LoadInto.
private NetworkEntity Spawn()Spawns a fresh entity of the saved prefab hash through the spawn manager. Used by the obsolete Load.

Used in​

Members of other types that take, return or hold a SerializedSavedDynamicObject: