mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Update SyncVarHook.md
In the example while reading the guides it just seemed easier to put the variables at the top (as you read the OnStartServer method you see a variable and try to find what it is, but it's further down. Easier to understand in my mind. Not sure if it's a huge issue for others
This commit is contained in:
parent
f521f1b06e
commit
a21ab8934b
@ -15,11 +15,6 @@ using UnityEngine.Networking;
|
||||
|
||||
public class PlayerController : NetworkBehaviour
|
||||
{
|
||||
public override void OnStartServer()
|
||||
{
|
||||
base.OnStartServer();
|
||||
playerColor = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
||||
}
|
||||
|
||||
[SyncVar(hook = nameof(SetColor))]
|
||||
Color playerColor = Color.black;
|
||||
@ -27,6 +22,12 @@ public class PlayerController : NetworkBehaviour
|
||||
// Unity makes a clone of the Material every time GetComponent<Renderer>().material is used.
|
||||
// Cache it here and Destroy it in OnDestroy to prevent a memory leak.
|
||||
Material cachedMaterial;
|
||||
|
||||
public override void OnStartServer()
|
||||
{
|
||||
base.OnStartServer();
|
||||
playerColor = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
||||
}
|
||||
|
||||
void SetColor(Color color)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user