protected BaseCommsTrigger() { Log = Logs.Create(LogCategory.Core, GetType().Name); }
[UsedImplicitly] private void Start() { //Ensure that all settings are loaded before we access them (potentially from other threads) ChatRoomSettings.Preload(); DebugSettings.Preload(); VoiceSettings.Preload(); //Write multithreaded logs ASAP so the logging system knows which is the main thread Logs.WriteMultithreadedLogs(); //Sanity check (can't run without a network object) var net = gameObject.GetComponent <ICommsNetwork>(); if (net == null) { throw new Exception("Cannot find a voice network component. Please attach a voice network component appropriate to your network system to the DissonanceVoiceComms' entity."); } //Sanity check (can't run without run in background). This value doesn't work on mobile platforms so don't perform this check there if (!Application.isMobilePlatform && !Application.runInBackground) { Log.Error(Log.UserErrorMessage( "Run In Background is not set", "The 'Run In Background' toggle on the player settings has not been checked", "https://dissonance.readthedocs.io/en/latest/Basics/Getting-Started/#3-run-in-background", "98D123BB-CF4F-4B41-8555-41CD01108DA7") ); } //Load default playback prefab if one has not been set if (PlaybackPrefab == null) { //Check if there is a legacy playback prefab set if (_playbackPrefab != null) { PlaybackPrefab = _playbackPrefab.gameObject; } else { Log.Info("Loading default playback prefab"); PlaybackPrefab = Resources.Load <GameObject>("PlaybackPrefab"); if (PlaybackPrefab == null) { throw Log.CreateUserErrorException("Failed to load PlaybackPrefab from resources - Dissonance voice will be disabled", "Incorrect installation of Dissonance", "https://dissonance.readthedocs.io/en/latest/Basics/Getting-Started/", "F542DAE5-AB78-4ADE-8FF0-4573233505AB"); } } } net.PlayerJoined += Net_PlayerJoined; net.PlayerLeft += Net_PlayerLeft; net.PlayerEnteredRoom += Net_PlayerRoomEvent; net.PlayerExitedRoom += Net_PlayerRoomEvent; net.VoicePacketReceived += Net_VoicePacketReceived; net.PlayerStartedSpeaking += Net_PlayerStartedSpeaking; net.PlayerStoppedSpeaking += Net_PlayerStoppedSpeaking; net.TextPacketReceived += _text.OnMessageReceived; //If an explicit name has not been set generate a GUID based name if (string.IsNullOrEmpty(LocalPlayerName)) { var guid = Guid.NewGuid().ToString(); LocalPlayerName = guid; } //mark this component as started, locking the LocalPlayerName, PlaybackPrefab and Microphone properties from changing _started = true; //Setup the playback pool so we can create pipelines to play audio _playbackPool.Start(PlaybackPrefab, transform); //Make sure we load up the codec settings so we can create codecs later _codecSettingsLoader.Start(); //Start the player collection (to set local name) _players.Start(LocalPlayerName, _capture, Rooms, RoomChannels, PlayerChannels, _capture); net.Initialize(LocalPlayerName, Rooms, PlayerChannels, RoomChannels, _codecSettingsLoader.Config); _net = net; //Begin capture manager, this will create and destroy capture pipelines as necessary (net mode changes, mic name changes, mic requires reset etc) _capture.MicrophoneName = _micName; _capture.Start(_net, GetOrAddMicrophone()); Log.Info("Starting Dissonance Voice Comms\n- Network: [{0}]\n- Quality Settings: [{1}]\n- Codec: [{2}]", _net, VoiceSettings.Instance, _codecSettingsLoader); }
private bool ShouldLog(LogLevel level) { return(level >= Logs.GetLogLevel(_category)); }