protected void AddNetworkVariable(Func<object> getter, Action<object> setter, NetSync netSync = null, bool manualProperty = false, bool serverOnly = false)
{
if (IsSetup)
throw new NetworkException(6, "Network variables can not be added after the Awake method of this MonoBehaviour");
Action callback = null;
NetworkCallers callers = NetworkCallers.Everyone;
NetSync.Interpolate useInterpolation = NetSync.Interpolate.True;
if (netSync != null)
{
if (!string.IsNullOrEmpty(netSync.method))
{
#if NETFX_CORE
callback = () => { this.GetType().GetRuntimeMethod(netSync.method, null).Invoke(this, new object[] { }); };
#else
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, netSync.method);
#endif
}
callers = netSync.callers;
useInterpolation = netSync.interpolate;
}
if (manualProperty)
ManualProperties.Add(new NetRef<object>(getter, setter, callback, callers, useInterpolation == NetSync.Interpolate.False));
else
Properties.Add(new NetRef<object>(getter, setter, callback, callers, useInterpolation == NetSync.Interpolate.False, serverOnly));
}