From 8aadd245fd7ecac8bedb5ad09068da4ee2eeff42 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Mon, 19 Aug 2019 16:52:41 -0500 Subject: [PATCH] Document correct dictionary initialization --- docs/Classes/SyncDictionary.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/Classes/SyncDictionary.md b/docs/Classes/SyncDictionary.md index a132105de..b17693742 100644 --- a/docs/Classes/SyncDictionary.md +++ b/docs/Classes/SyncDictionary.md @@ -14,8 +14,18 @@ A SyncDictionary is an associative array containing an unordered list of key, va SyncDictionary works much like [SyncLists](SyncLists): when you make a change on the server the change is propagated to all clients and the Callback is called. + + + To use it, create a class that derives from SyncDictionary for your specific type. This is necessary because the Weaver will add methods to that class. Then add a field to your NetworkBehaviour class. + + + ## Simple Example ```cs @@ -33,7 +43,7 @@ public class ExamplePlayer : NetworkBehaviour public int durability; } - public SyncDictionaryStringItem Equipment = new SyncDictionaryStringItem(); + public readonly SyncDictionaryStringItem Equipment = new SyncDictionaryStringItem(); public void OnStartServer() { @@ -68,6 +78,7 @@ public class ExamplePlayer : NetworkBehaviour public SyncDictionaryStringItem() : base (new SortedList()) {} } - public SyncDictionaryStringItem Equipment = new SyncDictionaryStringItem(); + public readonly SyncDictionaryStringItem Equipment = new SyncDictionaryStringItem(); } ``` +