Example #1
0
 public SpeakerObjectInfo(GameObject go, Vector3 vector3, Quaternion quaternion)
 {
     System.Diagnostics.Debug.Assert(go != null);
     voice    = go.GetComponent <MonobitVoice>();
     position = vector3;
     rotation = quaternion;
 }
Example #2
0
    /*
     * private void OnGUI()
     * {
     *
     *  //MUNサーバに接続している場合
     *  if (MonobitNetwork.isConnect)
     *  {
     *      // ルームに入室している場合
     *      if (MonobitNetwork.inRoom)
     *      {
     *          GUILayout.BeginHorizontal();
     *          //Debug.Log(MonobitEngine.MonobitNetwork.room.name);
     *          roomName = MonobitEngine.MonobitNetwork.room.name;
     *          RoomNameText.text = "roomName : " + roomName;
     *          GUILayout.Label("roomName : " + roomName, m_guiStyle);
     *          GUILayout.EndHorizontal();
     *          GUILayout.BeginHorizontal();
     *          GUILayout.Label("PlayerList : ", m_guiStyle);
     *          PlayerList.text = "PlayerList : ";
     *
     *
     *          //Debug.Log("PlayerList:");
     *          foreach (MonobitPlayer player in MonobitNetwork.playerList)
     *          {
     *              PlayerList.text = PlayerList.text + player.name + " ";
     *              GUILayout.Label(player.name + " ");
     *              //Debug.Log(player.name + " ");
     *          }
     *          GUILayout.EndHorizontal();
     *
     *          // ルームからの退室
     *          if (GUILayout.Button("Leave Room", m_guiStyle, GUILayout.Width(150)))
     *          {
     *              MonobitNetwork.LeaveRoom();
     *              //Debug.Log("ルームから退出しました");
     *              //ここでスタートのシーンに遷移する
     *              SceneManager.LoadScene("StartScene");
     *          }
     *
     *          if (myVoice != null)
     *          {
     *              // 送信タイプの設定
     *              GUILayout.BeginHorizontal();
     *              GUILayout.Label("VoiceChat Send Type : ", m_guiStyle);
     *              Int32 streamType = myVoice.SendStreamType == StreamType.BROADCAST ? 0 : 1;
     *              myVoice.SendStreamType = (StreamType)GUILayout.Toolbar(streamType, new string[] { "broadcast", "multicast" }, m_guiStyle);
     *              GUILayout.EndHorizontal();
     *
     *              // マルチキャスト送信の場合の、ボイスチャットの送信可否設定
     *              if (myVoice.SendStreamType == StreamType.MULTICAST)
     *              {
     *                  List<MonobitPlayer> playerList = new List<MonobitPlayer>(vcPlayerInfo.Keys);
     *                  List<MonobitPlayer> vcTargets = new List<MonobitPlayer>();
     *                  foreach (MonobitPlayer player in playerList)
     *                  {
     *                      // GUI による送信可否の切替
     *                      GUILayout.BeginHorizontal();
     *                      GUILayout.Label("PlayerName : " + player.name + " ", m_guiStyle);
     *                      GUILayout.Label("Send Permission: ", m_guiStyle);
     *                      vcPlayerInfo[player] = GUILayout.Toolbar(vcPlayerInfo[player], new string[] { "Allow", "Deny" }, m_guiStyle);
     *                      GUILayout.EndHorizontal();
     *                      // ボイスチャットの送信可のプレイヤー情報を登録する
     *                      if (vcPlayerInfo[player] == (Int32)EnableVC.ENABLE)
     *                      {
     *                          vcTargets.Add(player);
     *                      }
     *                  }
     *
     *                  // ボイスチャットの送信可否設定を反映させる
     *                  myVoice.SetMulticastTarget(vcTargets.ToArray());
     *              }
     *          }
     *
     *      }
     *  }
     * }
     */


    // 自身がルーム入室に成功したときの処理
    public void OnJoinedRoom()
    {
        vcPlayerInfo.Clear();
        vcPlayerInfo.Add(MonobitNetwork.player, (Int32)EnableVC.DISABLE);

        foreach (MonobitPlayer player in MonobitNetwork.otherPlayersList)
        {
            vcPlayerInfo.Add(player, (Int32)EnableVC.ENABLE);
        }

        GameObject go = MonobitNetwork.Instantiate("VoiceActor", Vector3.zero, Quaternion.identity, 0);

        myVoice = go.GetComponent <MonobitVoice>();

        Mc = go.GetComponent <MonobitMicrophone>();
        AC = Mc.GetAudioClip();

        Debug.Log(MonobitNetwork.playerName);

        if (myVoice != null)
        {
            myVoice.SetMicrophoneErrorHandler(OnMicrophoneError);
            myVoice.SetMicrophoneRestartHandler(OnMicrophoneRestart);
        }
    }
 /**
  * @brief	Inspector から削除されたときの処理.
  */
 public void OnDestroy()
 {
     m_Voice = target as MonobitVoice;
     if (m_Voice != null)
     {
         return;
     }
 }
 /**
  * @brief	Inspector に追加されたときの処理.
  */
 public void Awake()
 {
     // MonobitVoiceの取得
     m_Voice = target as MonobitVoice;
     if (m_Voice == null)
     {
         UnityEngine.Debug.LogErrorFormat("Voice object is null.");
         return;
     }
 }
        /**
         * @brief	Inspector上のGUI表示.
         */
        public override void OnInspectorGUI()
        {
            // 変数取得
            m_Voice = target as MonobitVoice;
            if (m_Voice == null)
            {
                return;
            }

            // Version
            EditorGUILayout.BeginHorizontal();
            GUI.enabled = false;
            EditorGUILayout.TextField("MonobitVoice Version", string.Format("0x{0:x8}", m_Voice.Version), EditorStyles.boldLabel);
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            // SendStreamType
            m_Voice.SendStreamType = (StreamType)EditorGUILayout.EnumPopup("Send Stream Type", m_Voice.SendStreamType);

            // ReliableMode
            m_Voice.ReliableMode = EditorGUILayout.Toggle("Reliable Mode", m_Voice.ReliableMode);

            // Encrypt
            m_Voice.Encrypt = EditorGUILayout.Toggle("Encrypt", m_Voice.Encrypt);

            // Surround 3D
            m_Voice.Surround3D = EditorGUILayout.Toggle("Surround 3D", m_Voice.Surround3D);

            // Call Bps Callback
            m_Voice.ShowVoiceDataBps = EditorGUILayout.Toggle("Call bps callback", m_Voice.ShowVoiceDataBps);

            // PlaybackVoice Local Check
            m_Voice.PlaybackVoiceLocalNoCheck = EditorGUILayout.Toggle("Playback Voice Local NoCheck", m_Voice.PlaybackVoiceLocalNoCheck);

            // Debug Mode
            m_Voice.DebugMode = EditorGUILayout.Toggle("Debug Mode", m_Voice.DebugMode);

            // VAD
            m_bVADFoldout = EditorGUILayout.Foldout(m_bVADFoldout, "Voice Activity Detector (VAD)");
            if (m_bVADFoldout)
            {
                EditorGUI.indentLevel = 1;
                SetupVAD();
                EditorGUI.indentLevel = 0;
            }

            // Opus Codecの設定
            m_bOpusCodecFoldout = EditorGUILayout.Foldout(m_bOpusCodecFoldout, "Opus Codec Settings");
            if (m_bOpusCodecFoldout)
            {
                EditorGUI.indentLevel = 1;
                SetupOpusCodec();
                EditorGUI.indentLevel = 0;
            }

            // セーブ
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(m_Voice);
                MonobitEditor.MarkSceneDirty();
            }
        }
Example #6
0
    // 自身がルーム入室に成功したときの処理
    public void OnJoinedRoom()
    {
        vcPlayerInfo.Clear();
        vcPlayerInfo.Add(MonobitNetwork.player, (Int32)EnableVC.DISABLE);

        foreach (MonobitPlayer player in MonobitNetwork.otherPlayersList)
        {
            vcPlayerInfo.Add(player, (Int32)EnableVC.ENABLE);
        }

        GameObject go = MonobitNetwork.Instantiate("VoiceActor", Vector3.zero, Quaternion.identity, 0);

        myVoice = go.GetComponent <MonobitVoice>();

        Mc = go.GetComponent <MonobitMicrophone>();
        AC = Mc.GetAudioClip();

        Debug.Log(MonobitNetwork.playerName);

        //7/2試行部分
        // ResourcesフォルダにあるNew SpriteプレハブをGameObject型で取得
        //GameObject obj = (GameObject)Resources.Load("icon");
        // iconプレハブを元に、インスタンスを生成、
        //Instantiate(obj, new Vector3(0.0f, 2.0f, 0.0f), Quaternion.identity);

        //7/6試行部分
        //GameObject user_icon= new GameObject("usericon");
        //user_icon.transform.parent = GameObject.Find("Canvas").transform;
        //user_icon.AddComponent<RectTransform>().anchoredPosition = new Vector3(0, 0, 0);
        //user_icon.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
        //user_icon.AddComponent<Image>().sprite = Resources.Load<Sprite>("textures/ifn0438");
        //7/7 user_icon.AddComponent<Image>().sprite = Resources.Load("textures/ifn0438", typeof(Sprite)) as Sprite;
        //user_icon.GetComponent<Image>().preserveAspect = true;
        //user_icon.GetComponent<Image>().SetNativeSize();

        // 「Sprite sprite = Resources.Load("ban", typeof(Sprite)) as Sprite;」と同じ
        //Sprite sprite = Resources.Load<Sprite>("ban");

        // 空のゲームオブジェクトを生成
        //GameObject gameObj = new GameObject();
        // Imageコンポーネントをアタッチ
        //Image image = gameObj.AddComponent<Image>();
        // Resources.Load()で生成したSpriteを指定
        //image.sprite = sprite;
        // Canvasの子オブジェクトとする
        //gameObj.transform.parent = FindObjectOfType<Canvas>().transform;

        // Texture2Dでサイズを取得し、変更する
        //Texture2D texture = Resources.Load<Texture2D>("ban");
        //gameObj.GetComponent<RectTransform>().sizeDelta = new Vector2(texture.width, texture.height);

        //7/7
        GameObject prefab = (GameObject)Instantiate(UserIcon);

        prefab.transform.SetParent(canvas.transform, false);

        if (myVoice != null)
        {
            myVoice.SetMicrophoneErrorHandler(OnMicrophoneError);
            myVoice.SetMicrophoneRestartHandler(OnMicrophoneRestart);
        }
    }