From 750f17e95f0694e393869358c43332c291d6af88 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Mon, 19 Aug 2019 16:48:38 -0500 Subject: [PATCH] Document list initialization --- docs/Classes/SyncLists.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/Classes/SyncLists.md b/docs/Classes/SyncLists.md index 52edcb900..340d9e9bb 100644 --- a/docs/Classes/SyncLists.md +++ b/docs/Classes/SyncLists.md @@ -42,7 +42,7 @@ class SyncListItem : SyncList {} class Player : NetworkBehaviour { - SyncListItem inventory = new SyncListItem(); + readonly SyncListItem inventory = new SyncListItem(); public int coins = 100; @@ -79,12 +79,20 @@ There are some ready made SyncLists you can use: - SyncListBool -You can also detect when a SyncList changes in the client or server. This is useful for refreshing your character when you add equipment or determining when you need to update your database. Subscribe to the Callback event typically during `Start`, `OnClientStart`, or `OnServerStart` for that. Note that by the time you subscribe, the list will already be initialized, so you will not get a call for the initial data, only updates. +You can also detect when a SyncList changes in the client or server. This is useful for refreshing your character when you add equipment or determining when you need to update your database. Subscribe to the Callback event typically during `Start`, `OnClientStart`, or `OnServerStart` for that. + + + + ```cs class Player : NetworkBehaviour { - SyncListItem inventory; + readonly SyncListItem inventory = new SyncListItem(); // this will add the delegates on both server and client. // Use OnStartClient instead if you just want the client to act upon updates