public override void OnInspectorGUI()
        {
            var comm = (DissonanceComms)target;

            using (var changed = new EditorGUI.ChangeCheckScope())
            {
                GUILayout.Label(_logo);

                CommsNetworkGui();
                DissonanceCommsGui();

                PlaybackPrefabGui(comm);

                comm.ChangeWithUndo(
                    "Changed Dissonance Mute",
                    EditorGUILayout.Toggle("Mute", comm.IsMuted),
                    comm.IsMuted,
                    a => comm.IsMuted = a
                    );

                comm.ChangeWithUndo(
                    "Changed Dissonance Deafen",
                    EditorGUILayout.Toggle("Deafen", comm.IsDeafened),
                    comm.IsDeafened,
                    a => comm.IsDeafened = a
                    );

                if (Application.isPlaying)
                {
                    EditorGUILayout.Space();
                    StatusGui(comm);
                }

                _tokenEditor.DrawInspectorGui(comm, comm);

                if (GUILayout.Button("Voice Settings"))
                {
                    VoiceSettingsEditor.GoToSettings();
                }

                if (GUILayout.Button("Configure Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }

                if (GUILayout.Button("Diagnostic Settings"))
                {
                    DebugSettingsEditor.GoToSettings();
                }

                Undo.FlushUndoRecordObjects();

                if (changed.changed)
                {
                    EditorUtility.SetDirty(comm);
                }
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
        }
        private void RoomsGui([NotNull] VoiceReceiptTrigger trigger)
        {
            var roomNames = _roomSettings.Names;

            var haveRooms = roomNames.Count > 0;

            if (haveRooms)
            {
                var roomList  = new List <string>(roomNames);
                var roomIndex = roomList.IndexOf(trigger.RoomName);
                var deadRoom  = false;

                using (new EditorGUILayout.HorizontalScope())
                {
                    //Detect if the room name is not null, and is also not in the list. This implies the room has been deleted from the room list. In this case
                    if (roomIndex == -1 && !string.IsNullOrEmpty(trigger.RoomName))
                    {
                        roomList.Insert(0, trigger.RoomName);
                        roomIndex = 0;
                        deadRoom  = true;
                    }

                    trigger.ChangeWithUndo(
                        "Changed Dissonance Receiver Room",
                        EditorGUILayout.Popup(new GUIContent("Chat Room", "The room to receive voice from"), roomIndex, roomList.Select(a => new GUIContent(a)).ToArray()),
                        roomIndex,
                        a => trigger.RoomName = roomList[a]
                        );

                    if (GUILayout.Button("Config Rooms"))
                    {
                        ChatRoomSettingsEditor.GoToSettings();
                    }
                }

                if (deadRoom)
                {
                    EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", trigger.RoomName), MessageType.Warning);
                }
                else if (string.IsNullOrEmpty(trigger.RoomName))
                {
                    EditorGUILayout.HelpBox("No chat room selected", MessageType.Error);
                }
            }
            else
            {
                if (GUILayout.Button("Create New Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }
            }

            if (!haveRooms)
            {
                EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
            }
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            CreateSkin();

            var comm = (DissonanceComms)target;

            GUILayout.Label(_logo);

            CommsNetworkGui();
            DissonanceCommsGui();

            PlaybackPrefabGui(comm);

            comm.ChangeWithUndo(
                "Changed Dissonance Mute",
                EditorGUILayout.Toggle("Mute", comm.IsMuted),
                comm.IsMuted,
                a => comm.IsMuted = a
                );

            comm.ChangeWithUndo(
                "Changed Dissonance Deafen",
                EditorGUILayout.Toggle("Deafen", comm.IsDeafened),
                comm.IsDeafened,
                a => comm.IsDeafened = a
                );

            EditorGUILayout.Space();

            if (Application.isPlaying)
            {
                StatusGui(comm);

                EditorGUILayout.Space();
            }

            _tokenEditor.DrawInspectorGui(comm, comm);

            if (GUILayout.Button("Voice Settings"))
            {
                VoiceSettingsEditor.GoToSettings();
            }

            if (GUILayout.Button("Configure Rooms"))
            {
                ChatRoomSettingsEditor.GoToSettings();
            }

            if (GUILayout.Button("Diagnostic Settings"))
            {
                DebugSettingsEditor.GoToSettings();
            }

            Undo.FlushUndoRecordObjects();
            EditorUtility.SetDirty(comm);
        }
示例#4
0
        private void RoomsGui(VoiceReceiptTrigger trigger)
        {
            var roomNames = _roomSettings.Names;

            var haveRooms = roomNames.Count > 0;

            if (haveRooms)
            {
                EditorGUILayout.BeginHorizontal();

                var selectedIndex = string.IsNullOrEmpty(trigger.RoomName) ? -1 : roomNames.IndexOf(trigger.RoomName);
                trigger.ChangeWithUndo(
                    "Changed Dissonance Receiver Room",
                    EditorGUILayout.Popup("Chat Room", selectedIndex, roomNames.ToArray()),
                    selectedIndex,
                    a => trigger.RoomName = roomNames[a]
                    );

                if (GUILayout.Button("Config Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }

                EditorGUILayout.EndHorizontal();

                if (string.IsNullOrEmpty(trigger.RoomName))
                {
                    EditorGUILayout.HelpBox("Please select a chat room", MessageType.Warning);
                }
                else if (!roomNames.Contains(trigger.RoomName))
                {
                    EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", trigger.RoomName), MessageType.Warning);
                }
            }
            else
            {
                if (GUILayout.Button("Create New Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }
            }

            if (!haveRooms)
            {
                EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
            }
        }
        private void ChannelTypeGui([NotNull] VoiceBroadcastTrigger transmitter)
        {
            transmitter.ChangeWithUndo(
                "Changed Dissonance Channel Type",
                (CommTriggerTarget)EditorGUILayout.EnumPopup(new GUIContent("Channel Type", "Where this trigger sends voice to"), transmitter.ChannelType),
                transmitter.ChannelType,
                a => transmitter.ChannelType = a
                );

            if (transmitter.ChannelType == CommTriggerTarget.Player)
            {
                transmitter.ChangeWithUndo(
                    "Changed Dissonance Channel Transmitter Player Name",
                    EditorGUILayout.TextField(new GUIContent("Recipient Player Name", "The name of the player receiving voice from this trigger"), transmitter.PlayerId),
                    transmitter.PlayerId,
                    a => transmitter.PlayerId = a
                    );

                EditorGUILayout.HelpBox("Player mode sends voice data to the specified player.", MessageType.None);
            }

            if (transmitter.ChannelType == CommTriggerTarget.Room)
            {
                var roomNames = _roomSettings.Names;

                var haveRooms = roomNames.Count > 0;
                if (haveRooms)
                {
                    var roomList  = new List <string>(roomNames);
                    var roomIndex = roomList.IndexOf(transmitter.RoomName);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        // Detect if the room name is not null, and is also not in the list. This implies the room has been deleted from the room list.
                        // If this is the case insert it into our temporary copy of the room names list
                        if (roomIndex == -1 && !string.IsNullOrEmpty(transmitter.RoomName))
                        {
                            roomList.Insert(0, transmitter.RoomName);
                            roomIndex = 0;
                        }

                        transmitter.ChangeWithUndo(
                            "Changed Dissonance Transmitter Room",
                            EditorGUILayout.Popup(new GUIContent("Chat Room", "The room to send voice to"), roomIndex, roomList.Select(a => new GUIContent(a)).ToArray()),
                            roomIndex,
                            a => transmitter.RoomName = roomList[a]
                            );

                        if (GUILayout.Button("Config Rooms"))
                        {
                            ChatRoomSettingsEditor.GoToSettings();
                        }
                    }

                    if (string.IsNullOrEmpty(transmitter.RoomName))
                    {
                        EditorGUILayout.HelpBox("No chat room selected", MessageType.Error);
                    }
                }
                else
                {
                    if (GUILayout.Button("Create New Rooms"))
                    {
                        ChatRoomSettingsEditor.GoToSettings();
                    }
                }

                EditorGUILayout.HelpBox("Room mode sends voice data to all players in the specified room.", MessageType.None);

                if (!haveRooms)
                {
                    EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
                }
            }

            if (transmitter.ChannelType == CommTriggerTarget.Self)
            {
                EditorGUILayout.HelpBox(
                    "Self mode sends voice data to the DissonancePlayer attached to this game object.",
                    MessageType.None
                    );

                var player = transmitter.GetComponent <IDissonancePlayer>() ?? transmitter.GetComponentInParent <IDissonancePlayer>();
                if (player == null)
                {
                    EditorGUILayout.HelpBox(
                        "This GameObject (and it's parent) does not have a Dissonance player component!",
                        MessageType.Error
                        );
                }
                else
                {
                    if (EditorApplication.isPlaying)
                    {
                        if (!player.IsTracking)
                        {
                            EditorGUILayout.HelpBox(
                                "The trigger is disabled because the player tracker script is not yet tracking the player",
                                MessageType.Warning
                                );
                        }

                        if (player.Type == NetworkPlayerType.Local)
                        {
                            EditorGUILayout.HelpBox(
                                "This trigger is disabled because the player tracker script represents the local player (cannot send voice to yourself).",
                                MessageType.Info
                                );
                        }

                        if (player.IsTracking && player.Type == NetworkPlayerType.Unknown)
                        {
                            EditorGUILayout.HelpBox(
                                "This trigger is disabled because the player tracker script is tracking an 'Unknown' player type. This is probably a bug in your player tracker script.",
                                MessageType.Error
                                );
                        }
                    }
                }
            }
        }
示例#6
0
        private void ChannelTypeGui(VoiceBroadcastTrigger transmitter)
        {
            transmitter.ChangeWithUndo(
                "Changed Dissonance Channel Type",
                (CommTriggerTarget)EditorGUILayout.EnumPopup("Channel Type", transmitter.ChannelType),
                transmitter.ChannelType,
                a => transmitter.ChannelType = a
                );

            if (transmitter.ChannelType == CommTriggerTarget.Player)
            {
                transmitter.ChangeWithUndo(
                    "Changed Dissonance Channel Transmitter Player Name",
                    EditorGUILayout.TextField("Recipient Player Name", transmitter.PlayerId),
                    transmitter.PlayerId,
                    a => transmitter.PlayerId = a
                    );

                EditorGUILayout.HelpBox("Player mode sends voice data to the specified player.", MessageType.None);
            }

            if (transmitter.ChannelType == CommTriggerTarget.Room)
            {
                var roomNames = _roomSettings.Names;

                var haveRooms = roomNames.Count > 0;
                if (haveRooms)
                {
                    EditorGUILayout.BeginHorizontal();

                    var selectedIndex = string.IsNullOrEmpty(transmitter.RoomName) ? -1 : roomNames.IndexOf(transmitter.RoomName);
                    transmitter.ChangeWithUndo(
                        "Changed Dissonance Transmitter Room",
                        EditorGUILayout.Popup("Chat Room", selectedIndex, roomNames.ToArray()),
                        selectedIndex,
                        a => transmitter.RoomName = roomNames[a]
                        );

                    if (GUILayout.Button("Config Rooms"))
                    {
                        ChatRoomSettingsEditor.GoToSettings();
                    }

                    EditorGUILayout.EndHorizontal();

                    if (string.IsNullOrEmpty(transmitter.RoomName))
                    {
                        EditorGUILayout.HelpBox("Please select a chat room", MessageType.Warning);
                    }
                    else if (!roomNames.Contains(transmitter.RoomName))
                    {
                        EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", transmitter.RoomName), MessageType.Warning);
                    }
                }
                else
                {
                    if (GUILayout.Button("Create New Rooms"))
                    {
                        ChatRoomSettingsEditor.GoToSettings();
                    }
                }

                EditorGUILayout.HelpBox("Room mode sends voice data to all players in the specified room.", MessageType.None);

                if (!haveRooms)
                {
                    EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
                }
            }

            if (transmitter.ChannelType == CommTriggerTarget.Self)
            {
                EditorGUILayout.HelpBox(
                    "Self mode sends voice data to the DissonancePlayer attached to this game object.",
                    MessageType.None
                    );

                var player = transmitter.GetComponent <IDissonancePlayer>();
                if (player == null)
                {
                    EditorGUILayout.HelpBox(
                        "This entity has no Dissonance player component!",
                        MessageType.Error
                        );
                }
                else if (Application.isPlaying && player.Type == NetworkPlayerType.Local)
                {
                    EditorGUILayout.HelpBox(
                        "This is the local player.\n" +
                        "Are you sure you mean to broadcast to the local player?",
                        MessageType.Warning
                        );
                }
            }
        }
示例#7
0
        private void ChannelTypeGui([NotNull] VoiceBroadcastTrigger transmitter)
        {
            transmitter.ChangeWithUndo(
                "Changed Dissonance Channel Type",
                (CommTriggerTarget)EditorGUILayout.EnumPopup(new GUIContent("Channel Type", "Where this trigger sends voice to"), transmitter.ChannelType),
                transmitter.ChannelType,
                a => transmitter.ChannelType = a
                );

            if (transmitter.ChannelType == CommTriggerTarget.Player)
            {
                transmitter.ChangeWithUndo(
                    "Changed Dissonance Channel Transmitter Player Name",
                    EditorGUILayout.TextField(new GUIContent("Recipient Player Name", "The name of the player receiving voice from this trigger"), transmitter.PlayerId),
                    transmitter.PlayerId,
                    a => transmitter.PlayerId = a
                    );

                EditorGUILayout.HelpBox("Player mode sends voice data to the specified player.", MessageType.None);
            }

            if (transmitter.ChannelType == CommTriggerTarget.Room)
            {
                var roomNames = _roomSettings.Names;

                var haveRooms = roomNames.Count > 0;
                if (haveRooms)
                {
                    var roomList  = new List <string>(roomNames);
                    var roomIndex = roomList.IndexOf(transmitter.RoomName);
                    var deadRoom  = false;

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        //Detect if the room name is not null, and is also not in the list. This implies the room has been deleted from the room list. In this case
                        if (roomIndex == -1 && !string.IsNullOrEmpty(transmitter.RoomName))
                        {
                            roomList.Insert(0, transmitter.RoomName);
                            roomIndex = 0;
                            deadRoom  = true;
                        }

                        transmitter.ChangeWithUndo(
                            "Changed Dissonance Transmitter Room",
                            EditorGUILayout.Popup(new GUIContent("Chat Room", "The room to send voice to"), roomIndex, roomList.Select(a => new GUIContent(a)).ToArray()),
                            roomIndex,
                            a => transmitter.RoomName = roomList[a]
                            );

                        if (GUILayout.Button("Config Rooms"))
                        {
                            ChatRoomSettingsEditor.GoToSettings();
                        }
                    }

                    if (deadRoom)
                    {
                        EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", transmitter.RoomName), MessageType.Warning);
                    }
                    else if (string.IsNullOrEmpty(transmitter.RoomName))
                    {
                        EditorGUILayout.HelpBox("No chat room selected", MessageType.Error);
                    }
                }
                else
                {
                    if (GUILayout.Button("Create New Rooms"))
                    {
                        ChatRoomSettingsEditor.GoToSettings();
                    }
                }

                EditorGUILayout.HelpBox("Room mode sends voice data to all players in the specified room.", MessageType.None);

                if (!haveRooms)
                {
                    EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
                }
            }

            if (transmitter.ChannelType == CommTriggerTarget.Self)
            {
                EditorGUILayout.HelpBox(
                    "Self mode sends voice data to the DissonancePlayer attached to this game object.",
                    MessageType.None
                    );

                var player = transmitter.GetComponent <IDissonancePlayer>();
                if (player == null)
                {
                    EditorGUILayout.HelpBox(
                        "This entity has no Dissonance player component!",
                        MessageType.Error
                        );
                }
                else
                {
                    if (!player.IsTracking)
                    {
                        EditorGUILayout.HelpBox("The trigger is disabled because the player tracker script is not yet tracking the player", MessageType.Warning);
                    }

                    if (Application.isPlaying && player.Type == NetworkPlayerType.Local)
                    {
                        EditorGUILayout.HelpBox(
                            "This is the local player.\n" +
                            "Are you sure you mean to broadcast to the local player?",
                            MessageType.Warning
                            );
                    }
                }
            }
        }
        private void RoomsGui([NotNull] VoiceReceiptTrigger trigger)
        {
            var roomNames = _roomSettings.Names;

            var haveRooms = roomNames.Count > 0;

            if (haveRooms)
            {
                EditorGUILayout.BeginHorizontal();

                var roomList  = roomNames;
                var roomIndex = -1;

                if (string.IsNullOrEmpty(trigger.RoomName))
                {
                    EditorGUILayout.LabelField("No room");
                }
                else
                {
                    roomIndex = roomList.IndexOf(trigger.RoomName);
                    if (roomIndex == -1)
                    {
                        roomList = new List <string>(roomList);
                        roomList.Insert(0, trigger.RoomName);
                        roomIndex = 0;
                    }
                }

                trigger.ChangeWithUndo(
                    "Changed Dissonance Receiver Room",
                    EditorGUILayout.Popup(new GUIContent("Chat Room", "The room to receive voice from"), roomIndex, roomList.Select(a => new GUIContent(a)).ToArray()),
                    roomIndex,
                    a => trigger.RoomName = roomNames[a]
                    );

                if (GUILayout.Button("Config Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }

                EditorGUILayout.EndHorizontal();

                if (string.IsNullOrEmpty(trigger.RoomName))
                {
                    EditorGUILayout.HelpBox("No chat room selected", MessageType.Error);
                }
                else if (!roomNames.Contains(trigger.RoomName))
                {
                    EditorGUILayout.HelpBox(string.Format("Room '{0}' is no longer defined in the chat room configuration! \nRe-create the '{0}' room, or select a different room.", trigger.RoomName), MessageType.Warning);
                }
            }
            else
            {
                if (GUILayout.Button("Create New Rooms"))
                {
                    ChatRoomSettingsEditor.GoToSettings();
                }
            }

            if (!haveRooms)
            {
                EditorGUILayout.HelpBox("No rooms are defined. Click 'Create New Rooms' to configure chat rooms.", MessageType.Warning);
            }
        }