public new void Destroy(int viewId) { var view = EiNetworkView.Find(viewId); if (view) { view.Destroy(); allocatedViews.Remove(viewId); } }
public void ReceiveRPC(byte[] rpcData) { EiBuffer buffer = new EiBuffer(rpcData); var viewId = buffer.ReadInt(); var methodId = buffer.ReadByte(); var array = buffer.ReadByteArray(rpcData.Length - 5); var view = EiNetworkView.Find(viewId); if (view) { //view.ReceiveRPC(methodId, array); } else { Debug.LogWarning("Received an RPC for a network View that does not exists"); } }
public void Instantiate(byte[] data) { EiBuffer buffer = new EiBuffer(data); var unpack = (EiNetworkInstantiateMask)buffer.ReadByte(); var prefabId = buffer.ReadInt(); var viewId = buffer.ReadInt(); var ownerId = buffer.ReadInt(); EiPrefab prefab = Eitrum.Database.EiPrefabDatabase.Instance [prefabId]; // Calculate Unpack type Vector3 position = unpack.HasFlag(EiNetworkInstantiateMask.Position) ? buffer.ReadVector3() : Vector3.zero; Quaternion rotation = unpack.HasFlag(EiNetworkInstantiateMask.Rotation) ? buffer.ReadQuaternion() : Quaternion.identity; float scale = unpack.HasFlag(EiNetworkInstantiateMask.Scale) ? buffer.ReadFloat() : 1f; Vector3 scale3D = unpack.HasFlag(EiNetworkInstantiateMask.Scale3D) ? buffer.ReadVector3() : new Vector3(scale, scale, scale); Transform parent = null; if (unpack.HasFlag(EiNetworkInstantiateMask.Parent)) { var parentViewId = buffer.ReadInt(); var parentView = EiNetworkView.Find(parentViewId); if (parentView) { parent = parentView.transform; } } // Instantiate Prefab var go = prefab.Instantiate(position, rotation, scale3D, parent); var view = go.GetComponent <EiNetworkView> (); if (view) { EiNetworkView.SetViewId(view, viewId); EiNetworkView.SetOwnerId(view, ownerId); EiNetworkView.SetNetwork(view, this); } }