示例#1
0
    private void Start()
    {
        _comms = FindObjectOfType <DissonanceComms>();

        //Update labels with session ID
        var sessionId = FindObjectOfType <PureP2PCommsNetwork>().SessionId;

        if (SessionIdLabels != null)
        {
            for (var i = 0; i < SessionIdLabels.Length; i++)
            {
                SessionIdLabels[i].text = sessionId;
            }
        }

        //Add all existing players
        foreach (var player in _comms.Players)
        {
            if (player.Name != _comms.LocalPlayerName)
            {
                PlayerJoined(player);
            }
        }

        _comms.OnPlayerJoinedSession += PlayerJoined;
    }
示例#2
0
        private void MicrophoneGui(DissonanceComms comm)
        {
            using (new EditorGUI.DisabledScope(Application.isPlaying))
            {
                var inputString = EditorGUILayout.DelayedTextField("Microphone Device Name", comm.MicrophoneName ?? "None (Default)");

                //If the name is any of these special string, default it back to null
                var nulls = new[] {
                    "null", "(null)",
                    "default", "(default)", "none default", "none (default)",
                    "none", "(none)"
                };
                if (string.IsNullOrEmpty(inputString) || nulls.Contains(inputString, StringComparer.InvariantCultureIgnoreCase))
                {
                    inputString = null;
                }

                if (!Application.isPlaying && comm.MicrophoneName != inputString)
                {
                    comm.ChangeWithUndo(
                        "Changed Dissonance Microphone",
                        inputString,
                        comm.MicrophoneName,
                        a => comm.MicrophoneName = a
                        );
                }
            }

            if (Application.isPlaying)
            {
                _micMeter.DrawInspectorGui(comm, (comm.MicCapture == null) ? 0 : comm.MicCapture.Amplitude, comm.IsMuted);
            }
        }
示例#3
0
        private static void StatusGui(DissonanceComms comm)
        {
            EditorGUILayout.LabelField("Local Player ID", comm.LocalPlayerName);
            EditorGUILayout.LabelField("Peers: (" + (comm.Players.Count == 0 ? "none" : comm.Players.Count.ToString()) + ")");

            for (var i = 0; i < comm.Players.Count; i++)
            {
                var p = comm.Players[i];

                //Skip the local player
                if (p.Name == comm.LocalPlayerName)
                {
                    continue;
                }

                var message = string.Format("{0} {1} {2} {3}",
                                            p.Name,
                                            p.IsSpeaking ? "(speaking)" : "",
                                            !p.IsConnected ? "(disconnected)" : "",
                                            p.Tracker != null && p.Tracker.IsTracking ? "(positional)" : ""
                                            );

                using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    EditorGUILayout.LabelField(message);
                    using (new EditorGUILayout.HorizontalScope())
                        p.IsLocallyMuted = GUILayout.Toggle(p.IsLocallyMuted, new GUIContent("Local Mute"));
                }

                //If there is a player we'll set the comms object to dirty which causes the editor to be redrawn.
                //This makes the (speaking) indicator update live for players.
                EditorUtility.SetDirty(comm);
            }
        }
示例#4
0
            public void Awake()
            {
                _net = FindObjectOfType <PureP2PCommsNetwork>();
                _net.InitializeAsClient(_sessionId);

                _comms = FindObjectOfType <DissonanceComms>();
            }
 private DissonanceComms FindComms()
 {
     if (!_comms)
     {
         _comms = FindObjectOfType <DissonanceComms>();
     }
     return(_comms);
 }
    private void Start()
    {
        _comms  = FindObjectOfType <DissonanceComms>();
        _player = _comms.FindPlayer(_comms.LocalPlayerName);

        // ReSharper disable once PossibleNullReferenceException
        NameText.text = _player.Name.MeaninglessString();
    }
        private void PlaybackPrefabGui([NotNull] DissonanceComms comm)
        {
            using (new EditorGUI.DisabledScope(Application.isPlaying))
            {
                var prefab = EditorGUILayout.ObjectField("Playback Prefab", comm.PlaybackPrefab, typeof(GameObject), false);
                if (!Application.isPlaying)
                {
                    // Check if we're in the special case of setting to nothing, when it's already nothing
                    if (prefab == null && comm.PlaybackPrefab == null)
                    {
                        //Display the last error
                        if (!string.IsNullOrEmpty(_lastPrefabError))
                        {
                            EditorGUILayout.HelpBox(_lastPrefabError, MessageType.Error);
                        }

                        return;
                    }

                    GameObject newPrefab = null;
                    if (prefab == null)
                    {
                        //Setting to null, no error involved with this
                        _lastPrefabError = null;
                    }
                    else if (PrefabUtility.GetPrefabType(prefab) == PrefabType.Prefab)
                    {
                        //Check that the prefab is valid
                        newPrefab = (GameObject)prefab;
                        if (newPrefab.GetComponent <VoicePlayback>() == null)
                        {
                            newPrefab        = null;
                            _lastPrefabError = "Playback Prefab must contain a VoicePlayback component";
                        }
                        else
                        {
                            _lastPrefabError = null;
                        }
                    }
                    else
                    {
                        _lastPrefabError = "Playback Prefab type must be user created prefab asset";
                    }

                    if (!string.IsNullOrEmpty(_lastPrefabError))
                    {
                        EditorGUILayout.HelpBox(_lastPrefabError, MessageType.Error);
                    }

                    comm.ChangeWithUndo(
                        "Changed Dissonance Playback Prefab",
                        ReferenceEquals(newPrefab, null) ? null : newPrefab.gameObject,
                        comm.PlaybackPrefab,
                        a => comm.PlaybackPrefab = a
                        );
                }
            }
        }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     if (isLocalPlayer)
     {
         ((Camera)camera.GetComponent <Camera>()).enabled = true;
         GameObject      dissonance = GameObject.Find("DissonanceSetup");
         DissonanceComms comms      = dissonance.GetComponent <DissonanceComms>();
         comms.IsMuted = true;
     }
 }
        public void Start()
        {
            Comms = Comms ?? FindObjectOfType <DissonanceComms>();

            _input = GetComponentsInChildren <InputField>().Single(a => a.name == "ChatInput");
            _input.gameObject.SetActive(false);

            _input.onEndEdit.AddListener(OnInputEndEdit);

            _log = GetComponent <ChatLogController>();
        }
示例#10
0
 public void SetPlayerId(string dissId)
 {
     _comms = FindObjectOfType <DissonanceComms>();
     if (_comms != null)
     {
         _playerId = dissId;
         _comms.TrackPlayerPosition(this);
         // _comms.
         _isTracking = true;
     }
 }
        private void StatusGui([NotNull] DissonanceComms comm)
        {
            EditorGUILayout.LabelField("Estimated Packet Loss", (comm.PacketLoss).ToString("0%"));

            var count = comm.Players.Count - 1;

            EditorGUILayout.LabelField("Peers: (" + (count == 0 ? "none" : count.ToString()) + ")");

            for (var i = 0; i < comm.Players.Count; i++)
            {
                var p = comm.Players[i];
                PlayerGui(p);
            }
        }
        private DissonanceComms FindComms()
        {
            if (!_comms)
            {
                var tgt = (MonoBehaviour)target;
                _comms = tgt.GetComponent <DissonanceComms>();
            }

            if (!_comms)
            {
                _comms = FindObjectOfType <DissonanceComms>();
            }

            return(_comms);
        }
示例#13
0
        public void Start()
        {
            Comms = Comms ?? FindObjectOfType <DissonanceComms>();

            _textPrototype = Resources.Load <GameObject>("LogTextPrototype");
            _canvas        = GetComponent <CanvasGroup>();

            _heightLimit = gameObject.GetComponent <RectTransform>().rect.height - 20;

            //Subscribe to receive Dissonance comms text messages
            if (Comms != null)
            {
                Comms.Text.MessageReceived += OnMessageReceived;
            }
        }
示例#14
0
        private IEnumerator StartTrackingCo()
        {
            // Wait until Dissonance comms object is initialised
            while (_comms == null)
            {
                _comms = FindObjectOfType <DissonanceComms>();
                yield return(null);
            }

            // Now start tracking
            _comms.TrackPlayerPosition(this);
            IsTracking = true;

            _startCo = null;
        }
示例#15
0
        public override void OnStartAuthority()
        {
            base.OnStartAuthority();
            DissonanceComms dissonanceComms = UnityEngine.Object.FindObjectOfType <DissonanceComms>();

            if (dissonanceComms == null)
            {
                throw HlapiPlayer.Log.CreateUserErrorException("cannot find DissonanceComms component in scene", "not placing a DissonanceComms component on a game object in the scene", "https://dissonance.readthedocs.io/en/latest/Basics/Quick-Start-UNet-HLAPI/", "9A79FDCB-263E-4124-B54D-67EDA39C09A5");
            }
            if (dissonanceComms.LocalPlayerName != null)
            {
                this.SetPlayerName(dissonanceComms.LocalPlayerName);
            }
            dissonanceComms.LocalPlayerNameChanged += this.SetPlayerName;
        }
示例#16
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Server finding:");
        GameObject managerObject = GameObject.Find("/DebateManager");

        Debug.Log(managerObject);
        mainManager = managerObject.GetComponent <debateManager>();
        Debug.Log(mainManager);

        if (isLocalPlayer)
        {
            ((Camera)camera.GetComponent <Camera>()).enabled = true;
            GameObject      dissonance = GameObject.Find("DissonanceSetup");
            DissonanceComms comms      = dissonance.GetComponent <DissonanceComms>();
            comms.IsMuted       = true;
            chatManager.enabled = true;
            camMove.enabled     = true;
            //canvas.SetActive(true);
        }
    }
示例#17
0
        private static void PlaybackPrefabGui([NotNull] DissonanceComms comm)
        {
            using (new EditorGUI.DisabledScope(Application.isPlaying))
            {
                var prefab = EditorGUILayout.ObjectField("Playback Prefab", comm.PlaybackPrefab, typeof(VoicePlayback), false);
                if (!Application.isPlaying)
                {
                    VoicePlayback newPrefab = null;
                    if (prefab != null && PrefabUtility.GetPrefabType(prefab) == PrefabType.Prefab)
                    {
                        newPrefab = (VoicePlayback)prefab;
                    }

                    comm.ChangeWithUndo(
                        "Changed Dissonance Playback Prefab",
                        newPrefab,
                        comm.PlaybackPrefab,
                        a => comm.PlaybackPrefab = a
                        );
                }
            }
        }
示例#18
0
        private void StatusGui([NotNull] DissonanceComms comm)
        {
            EditorGUILayout.LabelField("Local Player ID", comm.LocalPlayerName);
            _showLocalRooms = GUILayout.Toggle(_showLocalRooms, new GUIContent("Show Rooms (Listening To)"));

            if (_showLocalRooms)
            {
                using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                    foreach (var room in comm.Rooms.Memberships)
                    {
                        EditorGUILayout.LabelField(" - " + room);
                    }
            }

            EditorGUILayout.LabelField("Estimated Packet Loss", (comm.PacketLoss).ToString("0%"));

            var count = comm.Players.Count - 1;

            EditorGUILayout.LabelField("Peers: (" + (count == 0 ? "none" : count.ToString()) + ")");

            for (var i = 0; i < comm.Players.Count; i++)
            {
                var p = comm.Players[i];

                //Skip the local player
                if (p.Name == comm.LocalPlayerName)
                {
                    continue;
                }

                PlayerGui(p);

                //If there is a player we'll set the comms object to dirty which causes the editor to be redrawn.
                //This makes the (speaking) indicator update live for players.
                EditorUtility.SetDirty(comm);
            }
        }
示例#19
0
        void IPunInstantiateMagicCallback.OnPhotonInstantiate(PhotonMessageInfo info)
        {
            _comms = FindObjectOfType <DissonanceComms>();
            if (_comms == null)
            {
                throw Log.CreateUserErrorException(
                          "cannot find DissonanceComms component in scene",
                          "not placing a DissonanceComms component on a game object in the scene",
                          "https://dissonance.readthedocs.io/en/latest/Basics/Quick-Start-Photon/",
                          "00077AC8-3CBF-4DD8-A1C7-3ED3E8F64914");
            }

            if (info.Sender.IsLocal)
            {
                // This method is called on the client which has control authority over this object. This will be the local client of whichever player we are tracking.
                if (_comms.LocalPlayerName != null)
                {
                    SetPlayerName(_comms.LocalPlayerName);
                }

                //Subscribe to future name changes (this is critical because we may not have run the initial set name yet and this will trigger that initial call)
                _comms.LocalPlayerNameChanged += SetPlayerName;
            }
        }
示例#20
0
 public void OnEnable()
 {
     _comms = FindObjectOfType <DissonanceComms>();
     //create a new game object for the avatar to provide a valid game object before the avatar object is set by the spawn function in the networkplayer class
     Avatar = new GameObject();
 }
 public void OnEnable()
 {
     _comms = FindObjectOfType <DissonanceComms>();
 }