Property Code
v4.0
Last updated
v4.0
Last updated
The Property Code feature will export a script, Properties.cs, which contains an easy-to-reference set of properties leading to the uid and scriptable object for Game Module "Object" objects. (Stat, Condition, ItemObject etc)
You can access the Property Code window via Windows/Game Modules/Property Code, or from the links on each of the edit windows for Item Objects, Item Attributes, Conditions, and Stats.
if "Yes, auto export" is toggled on, the properties.cs script will be automatically updated as you create and manage your Game Module objects. However, you can manually update the script by simply clicking the "Export Now" button.
Exporting means overwriting the existing script. Best practice is to not modify the Properties.cs script, to avoid any issues.
Each time you create a new Item Object, Item Attribute, Condition, or Stat, or if you change their name, "type", or uid (changing the uid is not advised), you will need to re-export the Properties.cs script if auto export is not true.
If you're using it in your project, and names or types change, you will need to update code where you used the old name.
This is an example of how the script will look when exported. (It may not be formatted like this right away. Try deleting then adding the last "}" in the script to prompt Rider or your application to format it correctly).
There are classes for ItemObjects
, ItemAttributes
, Conditions
, and Stats
. Each "type" has a static class
, named the same as the type. Each object has a "Uid" variant which returns the string uid
, and a variant of it's own name which returns the Scriptable Object associated with that object.
The "Repository" prefabs are required for this to work. Be sure to include those prefabs in your scene.
As a reminder, the Scriptable Objects should not be edited at runtime. Use the "Game" version of each module to manage runtime data.
The Properties Code makes it easier to stay in the zone when scripting your project. Here's an example of two ways of getting a Stat
from the GameStatsList
script. The second example uses the Properties Code.