- Home /
SyncVar hook firing, but value passed is null
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class PrefabScript : NetworkBehaviour {
[SyncVar(hook="MakeTheChange")]
public Material material;
public Material newMaterial;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void MakeTheChange(Material value) {
GetComponent<MeshRenderer> ().material = value;
}
}
In the debugger, I can see MakeTheChange being called but value is alway null. Is there a limitation on what types can be synced? Any idea why value is null?
Comment
Answer by DarkestDay · Nov 28, 2015 at 09:29 AM
In case someone stumbles upon it - yes you can only syncvar the primitive types or Struct if you need a more complicated object. It is not clear from the documentation, alas
Your answer
Follow this Question
Related Questions
making a grappling hook/swinging rope in unity 2d? 0 Answers
Move towards connected body 1 Answer
In a native iOS App, how to send a message from Unity to iOS ? 1 Answer
Editor Compiling New Changes 2 Answers
How do i make a simple grappling hook? 0 Answers