/// <summary> /// Check the argument update with the stream and start index /// </summary> /// <param name="stream">Stream to be updated</param> /// <param name="start">Start index</param> public ulong SetupInstantiateId(NetworkingStream stream, int start) { ulong id = 0; if (MethodName == INSTANTIATE_METHOD_NAME) { string objName = stream.Bytes.GetString(start + 16); if (!NetworkingManager.TryPullIdFromObject(objName, ref id)) { throw new NetworkException("Invalid object being instantiated"); } if (id == 0) { throw new NetworkException("Invalid object being instantiated"); } idReplacer = BitConverter.GetBytes(id); for (int i = 0; i < idReplacer.Length; i++) { stream.Bytes.byteArr[start + sizeof(ulong) + i] = idReplacer[i]; } } return(id); }
/// <summary> /// Check the argument update with the stream and start index /// </summary> /// <param name="stream">Stream to be updated</param> /// <param name="start">Start index</param> public ulong SetupInstantiateId(NetworkingStream stream, int start) { ulong id = 0; if (MethodName == INSTANTIATE_METHOD_NAME) { // TODO: Debug log if start != 30 what it is equal to #if UNITY_EDITOR if (start != 30) { UnityEngine.Debug.LogError("The start value is not 30 it is " + start); } #endif // We add 16 because it is the size of 2 ulongs since the first 2 args of the instantiate are 2 ulongs string objName = stream.Bytes.GetString(30 + 16); if (!NetworkingManager.TryPullIdFromObject(objName, ref id)) { throw new NetworkException("Invalid object being instantiated"); } if (id == 0) { throw new NetworkException("Invalid object being instantiated"); } idReplacer = BitConverter.GetBytes(id); for (int i = 0; i < idReplacer.Length; i++) { stream.Bytes.byteArr[start + sizeof(ulong) + i] = idReplacer[i]; } } return(id); }