void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state) { for (int i = 1; i < attributeList.Length; ++i) { if (!getObservedState(i)) //如果editor中没有选择监控该属性 则直接跳过 { continue; } switch (i) { case 1: //position if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.position = FduInterpolationInterface.getNextVector3Value_new(_transform.position, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.position); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.position = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 2: //rotation if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.rotation = FduInterpolationInterface.getNextQuaternionValue_new(_transform.rotation, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendQuaternion(_transform.rotation); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state)); } break; case 3: //scale if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.localScale = FduInterpolationInterface.getNextVector3Value_new(_transform.localScale, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.localScale); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 4: //parent: 对于父节点的监控 这里只是一个不完全的解决方案 获取到父节点的路径 传输过去 然后在从节点解析。如果路径不唯一(因为可以同名)就会找不到对于的父节点 if (op == FduMultiAttributeObserverOP.SendData) { string parentPath; if (_transform.parent == null) { parentPath = ""; } else { parentPath = FduSupportClass.getGameObjectPath(_transform.parent.gameObject); } if (parentPath == null) { parentPath = ""; } BufferedNetworkUtilsServer.SendString(parentPath); } else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation) { string parentPath; if (_transform.parent == null) { parentPath = ""; } else { parentPath = FduSupportClass.getGameObjectPath(_transform.parent.gameObject); } if (parentPath == null) { parentPath = ""; } string getPath = BufferedNetworkUtilsClient.ReadString(ref state); if (parentPath != getPath) //hierarchy changed { GameObject go = FduSupportClass.getGameObjectByPath(getPath); if (go == null) { _transform.SetParent(null); } else { _transform.SetParent(go.transform); } } } break; case 5: //LocalPosition if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.localPosition = FduInterpolationInterface.getNextVector3Value_new(_transform.localPosition, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.localPosition); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.localPosition = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 6: //LocalRotation; if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.localRotation = FduInterpolationInterface.getNextQuaternionValue_new(_transform.localRotation, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendQuaternion(_transform.localRotation); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.localRotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state)); } break; case 7: //LocalScale if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.localScale = FduInterpolationInterface.getNextVector3Value_new(_transform.localScale, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.localScale); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 8: //EulerAngle if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.eulerAngles = FduInterpolationInterface.getNextVector3Value_new(_transform.eulerAngles, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.eulerAngles); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.eulerAngles = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 9: //LocalEulerAngle if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { _transform.localEulerAngles = FduInterpolationInterface.getNextVector3Value_new(_transform.localEulerAngles, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(_transform.localEulerAngles); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { _transform.localEulerAngles = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; default: break; } } }
void switchCaseFunc(FduMultiAttributeObserverOP op, ref NetworkState.NETWORK_STATE_TYPE state) { for (int i = 1; i < attrList.Length; ++i) { if (!getObservedState(i)) { continue; } switch (i) { case 1: //AnchoredPosition if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.anchoredPosition = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchoredPosition, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.anchoredPosition); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.anchoredPosition = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 2: //AnchoredPosition3D if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.anchoredPosition3D = FduInterpolationInterface.getNextVector3Value_new(rectTransform.anchoredPosition3D, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(rectTransform.anchoredPosition3D); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.anchoredPosition3D = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 3: //Rotation if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.rotation = FduInterpolationInterface.getNextQuaternionValue_new(rectTransform.rotation, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendQuaternion(rectTransform.rotation); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.rotation = BufferedNetworkUtilsClient.ReadQuaternion(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadQuaternion(ref state)); } break; case 4: //Scale if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.localScale = FduInterpolationInterface.getNextVector3Value_new(rectTransform.localScale, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector3(rectTransform.localScale); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.localScale = BufferedNetworkUtilsClient.ReadVector3(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty_append(i, BufferedNetworkUtilsClient.ReadVector3(ref state)); } break; case 5: //Parent if (op == FduMultiAttributeObserverOP.SendData) { string parentPath; if (rectTransform.parent == null) { parentPath = ""; } else { parentPath = FduSupportClass.getGameObjectPath(rectTransform.parent.gameObject); } if (parentPath == null) { parentPath = ""; } BufferedNetworkUtilsServer.SendString(parentPath); } else if (op == FduMultiAttributeObserverOP.Receive_Direct || op == FduMultiAttributeObserverOP.Receive_Interpolation) { string parentPath; if (rectTransform.parent == null) { parentPath = ""; } else { parentPath = FduSupportClass.getGameObjectPath(rectTransform.parent.gameObject); } if (parentPath == null) { parentPath = ""; } string getPath = BufferedNetworkUtilsClient.ReadString(ref state); if (parentPath != getPath) //hierarchy changed { GameObject go = FduSupportClass.getGameObjectByPath(getPath); if (go == null) { rectTransform.SetParent(null); } else { rectTransform.SetParent(go.transform); } } } break; case 6: //AnchorMax if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.anchorMax = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchorMax, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.anchorMax); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.anchorMax = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 7: //AnchorMin if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.anchorMin = FduInterpolationInterface.getNextVector2Value_new(rectTransform.anchorMin, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.anchorMin); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.anchorMin = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 8: //OffsetMax if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.offsetMax = FduInterpolationInterface.getNextVector2Value_new(rectTransform.offsetMax, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.offsetMax); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.offsetMax = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 9: //OffsetMin if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.offsetMin = FduInterpolationInterface.getNextVector2Value_new(rectTransform.offsetMin, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.offsetMin); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.offsetMin = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 10: //Pivot if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.pivot = FduInterpolationInterface.getNextVector2Value_new(rectTransform.pivot, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.pivot); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.pivot = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; case 11: //SizeDelta if (op == FduMultiAttributeObserverOP.Update) { if (getCachedProperytyCount(i) > 0) { rectTransform.sizeDelta = FduInterpolationInterface.getNextVector2Value_new(rectTransform.sizeDelta, i, this); } } else if (op == FduMultiAttributeObserverOP.SendData) { BufferedNetworkUtilsServer.SendVector2(rectTransform.sizeDelta); } else if (op == FduMultiAttributeObserverOP.Receive_Direct) { rectTransform.sizeDelta = BufferedNetworkUtilsClient.ReadVector2(ref state); } else if (op == FduMultiAttributeObserverOP.Receive_Interpolation) { setCachedProperty(i, BufferedNetworkUtilsClient.ReadVector2(ref state)); } break; } } }