internal void SetNetworkView(PNetC.NetworkView netView) { _networkView = netView; IsMine = netView.IsMine; OwnerId = netView.OwnerId; viewID = netView.ViewID; netView.StateSynchronization = _stateSynchronization.ToPNetC(); _networkView.OnDeserializeStream += StreamDeserializeCaller; _networkView.OnRemove += DoOnRemove; if (_queuedSer != null) { _networkView.SetSerializationMethod(_queuedSer, _queuedStreamSize); } var components = gameObject.GetComponents<MonoBehaviour>().OrderBy(c => c.name); foreach (var component in components) { SubscribeMarkedRPCsOnComponent(component); SubscribeSynchronizedFields(component); } }
public void Instantiate(string path, PNetC.NetworkView newView, PNetC.Vector3 location, PNetC.Quaternion rotation) { GameObject gobj; bool isCached = false; if (Net.resourceCaching && (isCached = ResourceCache.ContainsKey(path))) gobj = ResourceCache[path]; else gobj = Resources.Load(path) as GameObject; if (Net.resourceCaching && !isCached) ResourceCache.Add(path, gobj); var instance = (GameObject)Instantiate(gobj, new Vector3(location.X, location.Y, location.Z), new Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W)); if (instance == null) { Debug.LogWarning("could not find prefab " + path + " to instantiate"); instance = new GameObject("BROKEN NETWORK PREFAB " + newView.ViewID); } UnityDebugLogger.Full("network instantiate of {0}. Loc: {1} Rot: {2}", null, path, location, rotation); //look for a networkview.. var view = instance.GetComponent<NetworkView>(); if (view == null) view = instance.AddComponent<NetworkView>(); _manager.AddView(newView, view); var nBehaviours = instance.GetComponents<NetBehaviour>(); foreach (var behave in nBehaviours) { behave.netView = view; view.OnFinishedCreation += behave.CallFinished; } view.DoOnFinishedCreation(); }
internal void AddView(PNetC.NetworkView newView, NetworkView view) { _networkViews.Add(newView.ViewID, view); view.SetNetworkView(newView); }
/// <summary> /// Connect with the specified configuration /// </summary> /// <param name="configuration"></param> public static void Connect(PNetC.ClientConfiguration configuration) { Peer.Connect(configuration); }
void ILogger.Error(PNetC.Net sender, string info, params object[] args) { UnityEngine.Debug.LogError(string.Format(info, args)); }
void ILogger.Info(PNetC.Net sender, string info, params object[] args) { if (Network.logLevel > NetworkLogLevel.Off || UnityEngine.Debug.isDebugBuild) UnityEngine.Debug.Log(string.Format(info, args)); }
void ILogger.Full(PNetC.Net sender, string info, params object[] args) { if (Network.logLevel == NetworkLogLevel.Full) UnityEngine.Debug.Log(string.Format(info, args)); }
public void Error(PNetC.Net sender, string info, params object[] args) { Assert.Fail(info, args); }
public void Warning(PNetC.Net sender, string info, params object[] args) { Debug.WriteLine(string.Format(info, args)); }
public void AddNetworkView(PNetC.NetworkView view, PNetC.NetworkView newView, string customFunction) { NetworkView uview; if (!_manager.TryGetView(view.ViewID, out uview)) { Debug.LogError( string.Format("Could not attach extra networkview {0} to networkview {1}. It might have been destroyed accidentally, or not yet instantiated", newView.ViewID, view.ViewID)); } var unewView = uview.gameObject.AddComponent<NetworkView>(); _manager.AddView(newView, unewView); UnityDebugLogger.Info("Attached extra networkview " + newView.ViewID.guid, uview.gameObject); if (!string.IsNullOrEmpty(customFunction)) uview.gameObject.SendMessage(customFunction, unewView, SendMessageOptions.DontRequireReceiver); }