Graph Data
Inherits from ScriptableObject
Description
ScriptableObject that holds all the information about TerraTiler2D graphs. Is used for saving and loading TerraTiler2D graphs.
Use this class with the Graph Runner singleton to run graphs during runtime.
You should not need to edit this class, unless you add a specific kind of data that is not yet supported.
If you are having trouble with getting and setting properties, or saving and loading graph data, feel free to ask for help on the forums or in our Discord server, or check out the Properties Demo included with TerraTiler2D.
Methods
Name Return type Description
GetPropertyValue<T>(string name) T Get the value of an unprocessed graph property of type 'T' with name 'name'.

Value types that are not serializable by default require you to use a serializable alternative. Some serializable alternatives can be found in the static 'Serializable' class.
Currently supported unserializable types: Vector2, Vector3, Vector4, Color, Gradient, Texture2D, Tile, and World.
Example: Use 'Serializable.Vector2' as type T instead of 'Vector2'.
SetPropertyValue<T>(string name, T value) void Set the value of an unprocessed graph property of type 'T' with name 'name'. This is useful for changing the behaviour of a graph before running it.
Changing properties in this way is not persistent throughout different play sessions. Use SaveSerializedData and LoadSerializedPropertyData to persistently save and load property values.

Value types that are not serializable by default require you to use a serializable alternative. Some serializable alternatives can be found in the static 'Serializable' class.
Currently supported unserializable types: Vector2, Vector3, Vector4, Color, Gradient, Texture2D, Tile, and World.
Example: Use 'Serializable.Vector2' as type T instead of 'Vector2'.
SaveSerializedData(string saveName = "") void Save the current state of the GraphData on the local machine with file name 'saveName.dat', including any changes done to property values. This is useful for creating persistent save states for your game.

Example: Your player has unlocked an achievement, and by doing so has unlocked a new kind of biome that can spawn in your world. Set the value of boolean property "UnlockedBiome" to true, and save this. The next time the player loads up the game, load the save file, and the property should be set to true automatically.
An example of saving and loading can be seen in the Properties Demo.
LoadSerializedPropertyData(string saveName = "") GraphData Load data from a save file from the local machine with file name 'saveName.dat' into this GraphData object. This method only overwrites the values of properties, and is able to merge most save files with different versions without issues.

When loading data, it is good practice to not load the data directly into your GraphData ScriptableObject. Instead, use 'Instantiate(yourGraphData);' to create an instance of your GraphData, load the data into the instance, and use the instance in your scripts. This ensures that you don’t accidentally overwrite existing data that you wanted to keep.
LoadSerializedData(string saveName = "") GraphData Load data from a save file from the local machine with file name 'saveName.dat' into this GraphData object. This method overwrites all of the data, including properties, nodes, edges, and port values. It is advised to use LoadSerializedPropertyData instead of this method, as this method may cause unwanted behaviour when loading GraphData with a different graph Flow.

When loading data, it is good practice to not load the data directly into your GraphData ScriptableObject. Instead, use 'Instantiate(yourGraphData);' to create an instance of your GraphData, load the data into the instance, and use the instance in your scripts. This ensures that you don’t accidentally overwrite existing data that you wanted to keep.
Other methods (AddNodeData, AddPropertyData, GetAllPortData, etc.) / Most of the other methods on this class are not needed for normal use of TerraTiler2D. These other methods are used by singletons like GraphSaveManager for saving and loading graph data, and have little other uses.