public void OnMonobitSerializeView(MonobitStream stream, MonobitMessageInfo info) { if (stream.isWriting) { stream.Enqueue(playerName); stream.Enqueue(vrmTitle); } else { playerName = (string)stream.Dequeue(); vrmTitle = (string)stream.Dequeue(); } }
/// <summary> /// アニメーションレイヤー&パラメータを受信データからデシリアライズ /// </summary> /// <param name="stream">アニメーションレイヤー&パラメータを受信データからデシリアライズ</param> private void Deserialize(MonobitStream stream) { // アニメーションレイヤーを受信データからデシリアライズ foreach (AnimLayerInfo layerInfo in this.m_SyncAnimLayers) { if (layerInfo.m_EnableSync) { this.m_Animator.SetLayerWeight(layerInfo.m_Index, (float)stream.Dequeue()); } } // アニメーションパラメータを受信データからデシリアライズ foreach (AnimParamInfo paramInfo in this.m_SyncAnimParams) { if (paramInfo.m_EnableSync && !m_Animator.IsParameterControlledByCurve(paramInfo.m_Name)) { switch (paramInfo.m_Type) { case AnimatorControllerParameterType.Bool: if (stream.Peek() is bool) { this.m_Animator.SetBool(paramInfo.m_Name, (bool)stream.Dequeue()); } break; case AnimatorControllerParameterType.Float: if (stream.Peek() is float) { this.m_Animator.SetFloat(paramInfo.m_Name, (float)stream.Dequeue()); } break; case AnimatorControllerParameterType.Int: if (stream.Peek() is int) { this.m_Animator.SetInteger(paramInfo.m_Name, (int)stream.Dequeue()); } break; case AnimatorControllerParameterType.Trigger: break; } } } }
/** * 読み込み専用オブジェクトの位置・姿勢・倍率の同期処理関数. * * @param stream MonobitTransformViewの送信データ、または受信データのいずれかを提供するパラメータ * @param info 特定のメッセージやRPCの送受信、または更新に関する「送信者、対象オブジェクト、タイムスタンプ」などの情報を保有するパラメータ */ public override void OnMonobitSerializeViewRead(MonobitStream stream, MonobitMessageInfo info) { // ネットワークからの更新を受信したことをフラグで検知 m_UpdateNetwork = true; // ストリームからの受信処理 if (m_SyncPosition.m_EnableSync) { m_LastUpdatePosition = (Vector3)stream.Dequeue(); } if (m_SyncRotation.m_EnableSync) { m_LastUpdateRotation = (Quaternion)stream.Dequeue(); } if (m_SyncScale.m_EnableSync) { m_LastUpdateScale = (Vector3)stream.Dequeue(); } }
/** * オブジェクトの位置・姿勢・倍率の同期処理関数. * * @param stream MonobitTransformViewの送信データ、または受信データのいずれかを提供するパラメータ * @param info 特定のメッセージやRPCの送受信、または更新に関する「送信者、対象オブジェクト、タイムスタンプ」などの情報を保有するパラメータ */ public void OnMonobitSerializeView(MonobitStream stream, MonobitMessageInfo info) { if (stream.isWriting) { // ストリームへの送信処理、および、自身の座標を最新のtransform情報に更新 if (m_SyncPosition.m_EnableSync) { stream.Enqueue(gameObject.transform.localPosition); m_LastUpdatePosition = gameObject.transform.localPosition; } if (m_SyncRotation.m_EnableSync) { stream.Enqueue(gameObject.transform.localRotation); m_LastUpdateRotation = gameObject.transform.localRotation; } if (m_SyncScale.m_EnableSync) { stream.Enqueue(gameObject.transform.localScale); m_LastUpdateScale = gameObject.transform.localScale; } } else { // ネットワークからの更新を受信したことをフラグで検知 m_UpdateNetwork = true; // ストリームからの受信処理 if (m_SyncPosition.m_EnableSync) { m_LastUpdatePosition = (Vector3)stream.Dequeue(); } if (m_SyncRotation.m_EnableSync) { m_LastUpdateRotation = (Quaternion)stream.Dequeue(); } if (m_SyncScale.m_EnableSync) { m_LastUpdateScale = (Vector3)stream.Dequeue(); } } }
/// <summary> /// ストリームデータから指定形式にデシリアライズする /// </summary> /// <typeparam name="T">指定デシリアライズタイプ</typeparam> /// <param name="stream">ストリームデータ</param> /// <param name="procs">ストリームからのデータを設定するデリゲート</param> private void Desirialize <T>(MonobitStream stream, params Desirializer[] procs) { if (stream == null || procs == null || procs.Length == 0) { return; } if (typeof(T) == typeof(MonobitEngineBase.OnSerializeTransform)) { foreach (Desirializer proc in procs) { proc(stream.Dequeue()); } } else if (typeof(T) == typeof(MonobitEngineBase.OnSerializeRigidBody)) { for (int i = 0; i < 2; i++) { procs[i](stream.Dequeue()); } } }
public void OnMonobitSerializeView(MonobitStream stream, MonobitMessageInfo info) { if (stream.isWriting) { stream.Enqueue(serializeBytes); } else { serializeBytes = (byte[])stream.Dequeue(); if (MonobitEngineBase.CompressedStream.DeltaCompressed == monobitView.compressedStream) { ++serializeReadCount; UnityEngine.Debug.Log("serializeBytes[0]=" + serializeBytes[0] + " serializeReadCount=" + serializeReadCount); } } }
public override void OnMonobitSerializeViewRead(MonobitStream stream, MonobitMessageInfo info) { Active = (bool)stream.Dequeue(); lookAtObject.localPosition = (Vector3)stream.Dequeue(); lookAtObject.localRotation = (Quaternion)stream.Dequeue(); waist.localPosition = (Vector3)stream.Dequeue(); waist.localRotation = (Quaternion)stream.Dequeue(); handL.enable = (bool)stream.Dequeue(); handR.enable = (bool)stream.Dequeue(); footL.enable = (bool)stream.Dequeue(); footR.enable = (bool)stream.Dequeue(); handL.target.localRotation = (Quaternion)stream.Dequeue(); handR.target.localRotation = (Quaternion)stream.Dequeue(); footL.target.localRotation = (Quaternion)stream.Dequeue(); footR.target.localRotation = (Quaternion)stream.Dequeue(); handL.target.localPosition = (Vector3)stream.Dequeue(); handR.target.localPosition = (Vector3)stream.Dequeue(); footL.target.localPosition = (Vector3)stream.Dequeue(); footR.target.localPosition = (Vector3)stream.Dequeue(); handL.weight = (float)stream.Dequeue(); handR.weight = (float)stream.Dequeue(); footL.weight = (float)stream.Dequeue(); footR.weight = (float)stream.Dequeue(); }