# Basic

The Basic Example illustrates how to manage UI objects from the Player object using locally instantiated `PlayerUI` prefabs with [SyncVars](https://mirror-networking.gitbook.io/docs/manual/guides/synchronization/syncvars) and Events

<div align="left"><img src="https://462154250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGmQrf2z6FL0ZpExPAn%2Fuploads%2FEisctczKlZTsVAKaKz5q%2Fimage.png?alt=media&#x26;token=03771d14-0155-4b44-83d2-edf61dffc687" alt=""></div>

The scene Canvas has a `CanvasUI` script with references to its children:

<div align="left"><img src="https://462154250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGmQrf2z6FL0ZpExPAn%2Fuploads%2FB9TOxdEB7EvLv2MppZIf%2Fimage.png?alt=media&#x26;token=8f6a0acc-f1cc-4803-bb32-c1364f0cfdb1" alt="Scene Canvas"></div>

The `PlayerUI` prefab is a UI fragment that has a `PlayerUI` script with references to its own children:

<div align="left"><img src="https://462154250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGmQrf2z6FL0ZpExPAn%2Fuploads%2F8rczNg7Jr5ccOICoN5aP%2Fimage.png?alt=media&#x26;token=b672c056-1b3d-4fda-b48a-5beceb260ade" alt="PlayerUI Prefab"></div>

The Player script on the Player object has a reference to the `PlayerUI` prefab and three `SyncVars`:

<div align="left"><img src="https://462154250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGmQrf2z6FL0ZpExPAn%2Fuploads%2FpRIedJ2gjKa92TjReq2T%2Fimage.png?alt=media&#x26;token=9768456d-0cea-400a-8cf7-3a50fe7c29d2" alt="Player Object"></div>

The Player script also has three events that are invoked by the [SyncVar hooks](https://mirror-networking.gitbook.io/docs/manual/guides/synchronization/syncvar-hooks):

```
public event System.Action<int> OnPlayerNumberChanged;
public event System.Action<Color32> OnPlayerColorChanged;
public event System.Action<int> OnPlayerDataChanged;
```

When the Player object is spawned on the client, a `PlayerUI` is instantiated as a child of the `PlayersPanel` in the Canvas via the references provided in the `CanvasUI` script, and the `SetPlayer` method is called with the corresponding Player script reference.  The `PlayerUI` script subscribes to the events above, and updates its UI elements as the `SyncVars` are updated from the server.
