//Only called in matser node 通知一个新的view出现 public static void NotifyOneNewViewAppear(int assetId, FduClusterView view) { ClusterGameObjectCreatePara para = new ClusterGameObjectCreatePara(view.ViewId, assetId, view.transform.position, view.transform.rotation); if (view.transform.parent != null) { para.parentPath = FduSupportClass.getGameObjectPath(view.transform.parent.gameObject); } para.viewInstance = view; var subViews = view.getSubViews(); if (subViews != null) { for (int i = 0; i < subViews.Count; ++i) { if (subViews[i] != null) { if (!subViews[i].gameObject.activeSelf) { subViews[i].ObjectID = FduSyncBaseIDManager.ApplyNextAvaliableId(); FduClusterViewManager.RegistToViewManager(subViews[i]); } } else { Debug.LogError("Find Invalid sub view in one FduClusterView.View id :" + view.ViewId + " Object name:" + view.name + ". Please press the Refresh Button in Inspector"); } } } if (_waitForCreateList.Count == 0) { levelPrefix = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; } _waitForCreateList.Add(para); }
//解析需要创建和销毁的数据 并通知对应类完成创建和销毁工作 public override NetworkState.NETWORK_STATE_TYPE Deserialize() { NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS; string sceneName = BufferedNetworkUtilsClient.ReadString(ref state); int count = BufferedNetworkUtilsClient.ReadInt(ref state); int viewId, assetId, subViewCount, viewObCount; Vector3 position; Quaternion rotation; string path; for (int i = 0; i < count; i++) { viewId = BufferedNetworkUtilsClient.ReadInt(ref state); assetId = BufferedNetworkUtilsClient.ReadInt(ref state); position = BufferedNetworkUtilsClient.ReadVector3(ref state); rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state); path = BufferedNetworkUtilsClient.ReadString(ref state); ClusterGameObjectCreatePara para = new ClusterGameObjectCreatePara(viewId, assetId, position, rotation, path); viewObCount = BufferedNetworkUtilsClient.ReadInt(ref state); if (viewObCount > 0) { para.viewFrameCount = new Dictionary <int, int>(); for (int j = 0; j < viewObCount; ++j) { int obId = BufferedNetworkUtilsClient.ReadInt(ref state); int obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); para.viewFrameCount.Add(obId, obFrameCount); } } subViewCount = BufferedNetworkUtilsClient.ReadInt(ref state); if (subViewCount > 0) { para.subViewId = new List <int>(); para.subViewFrameCount = new List <Dictionary <int, int> >(); } for (int j = 0; j < subViewCount; ++j) { para.subViewId.Add(BufferedNetworkUtilsClient.ReadInt(ref state)); int obCount = BufferedNetworkUtilsClient.ReadInt(ref state); para.subViewFrameCount.Add(new Dictionary <int, int>()); for (int k = 0; k < obCount; ++k) { var oneSubViewData = para.subViewFrameCount[para.subViewFrameCount.Count - 1]; var obId = BufferedNetworkUtilsClient.ReadInt(ref state); var obFrameCount = BufferedNetworkUtilsClient.ReadInt(ref state); oneSubViewData.Add(obId, obFrameCount); } } _waitForCreateList.Add(para); } count = BufferedNetworkUtilsClient.ReadInt(ref state); for (int i = 0; i < count; ++i) { _wairForDestoryList.Add(BufferedNetworkUtilsClient.ReadInt(ref state)); } count = BufferedNetworkUtilsClient.ReadInt(ref state); for (int i = 0; i < count; ++i) { SyncViewIdData data = new SyncViewIdData(); data.name = BufferedNetworkUtilsClient.ReadString(ref state); data.id = BufferedNetworkUtilsClient.ReadInt(ref state); _waitForAssignViewIdList.Add(data); } if (BufferedNetworkUtilsClient.ReadString(ref state) != "FduClusterViewManagerEndFlag") { Debug.LogError("Wrong end of FduClusterViewManagerEndFlag!"); } if (sceneName == UnityEngine.SceneManagement.SceneManager.GetActiveScene().name) { ProcessCreateRequest(); ProcessDestoryRequest(); ProcessAssignViewIdRequest(); } ClearListData(); return(state); }