/* * 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); } }
// 自身がルーム入室に成功したときの処理 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); } }