Description
The SerializedPairs
property provides access to the serialized form of the Pairs
property within the CollisionRules
class. This property is used for JSON serialization and deserialization, allowing the collision rules to be easily stored and transmitted in a JSON format.
Usage
Use the SerializedPairs
property to get or set the collision pairs in a JSON-compatible format. This is particularly useful when you need to serialize the collision rules for storage or network transmission.
When setting this property, ensure that the JSON structure matches the expected format for collision pairs, as this will be deserialized into the Pairs
dictionary.
Example
// Example of accessing SerializedPairs
CollisionRules collisionRules = new CollisionRules();
// Get the serialized JSON node of collision pairs
JsonNode serializedPairs = collisionRules.SerializedPairs;
// Set the serialized JSON node of collision pairs
collisionRules.SerializedPairs = JsonNode.Parse("{ 'Pairs': { 'ObjectA-ObjectB': 'Collide', 'ObjectC-ObjectD': 'Ignore' } }");