Next: , Previous: , Up: Serialization   [Contents][Index]


15.3 Unique Object Serializer

Component: UniqueObjectSerializer

Unique Object Serializer allows you to save & load one object field in your game. This is for *unique* fields. So, for example, if you try to save the enemy’s health, then when you load the game *every* enemy with that prefab will load the health of the last one to save with that ’File Name’. But, if you save the Player’s health, that is fine since there is only one local player at a time so there are no duplicates to cause errors. This is great for saving things like user preferences. This component saves to a binary file, and therefore does not work on web builds.

Required Field of UniqueObjectSerializer: string targetField

What is the data name of the field. This is the name in program code, which you can usually determine by looking at the Inspector. Unity capitalizes the first letter and adds a space before each capital letter in the Inspector. So a field with name ’Monster Health’ is called ’monsterHealth’ in code and that is how you must write it here. For some script packages, you might need to look at the code by viewing the script in the Inspector first if possible.

Default value: ""

Required Field of UniqueObjectSerializer: string fileName

A unique file name for this one, if you have multiple fields you want to save with the same name then you can add a file name to each one to save them separately.

Default value: ""

Available Messages

Message on UniqueObjectSerializer: Save ()

Saves the ’Target Field’ from ’Target Component’ into ’File Name’

Message on UniqueObjectSerializer: Load ()

Loads ’Target Field’ from ’File Name’ and reassigns it’s value from disk.

Required Field of UniqueObjectSerializer: string targetField

What is the data name of the field. This is the name in program code, which you can usually determine by looking at the Inspector. Unity capitalizes the first letter and adds a space before each capital letter in the Inspector. So a field with name ’Monster Health’ is called ’monsterHealth’ in code and that is how you must write it here. For some script packages, you might need to look at the code by viewing the script in the Inspector first if possible.

Default value: ""

Required Field of UniqueObjectSerializer: string fileName

A unique file name for this one, if you have multiple fields you want to save with the same name then you can add a file name to each one to save them separately.

Default value: ""

Available Messages

Message on UniqueObjectSerializer: Save ()

Saves the ’Target Field’ from ’Target Component’ into ’File Name’

Message on UniqueObjectSerializer: Load ()

Loads ’Target Field’ from ’File Name’ and reassigns it’s value from disk.


Next: , Previous: , Up: Serialization   [Contents][Index]