예제 #1
0
        private void OnEnable()
        {
            // Note that we initialize the slider BEFORE we listen for changes (so we don't get notified of our own change!)
            m_MasterVolumeSlider.value = ClientPrefs.GetMasterVolume();
            m_MasterVolumeSlider.onValueChanged.AddListener(OnMasterVolumeSliderChanged);

            // initialize music slider similarly.
            m_MusicVolumeSlider.value = ClientPrefs.GetMusicVolume();
            m_MusicVolumeSlider.onValueChanged.AddListener(OnMusicVolumeSliderChanged);
        }
        private static void ConnectClient(GameNetPortal portal)
        {
            var clientGuid = ClientPrefs.GetGuid();
            //var payload = $"client_guid={clientGuid}\n"; //minimal format where key=value pairs are separated by newlines.
            //payload += $"client_scene={UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex}\n";
            //payload += $"player_name={portal.PlayerName}\n";
            var payload = JsonUtility.ToJson(new ConnectionPayload()
            {
                clientGUID = clientGuid, clientScene = SceneManager.GetActiveScene().buildIndex, playerName = portal.PlayerName
            });

            var payloadBytes = System.Text.Encoding.UTF8.GetBytes(payload);

            portal.NetManager.NetworkConfig.ConnectionData = payloadBytes;
            portal.NetManager.NetworkConfig.ClientConnectionBufferTimeout = k_TimeoutDuration;

            //and...we're off! MLAPI will establish a socket connection to the host.
            //  If the socket connection fails, we'll hear back by [???] (FIXME: GOMPS-79, need to handle transport layer failures too).
            //  If the socket connection succeeds, we'll get our RecvConnectFinished invoked. This is where game-layer failures will be reported.
            portal.NetManager.StartClient();
        }
예제 #3
0
 private void OnMusicVolumeSliderChanged(float newValue)
 {
     ClientPrefs.SetMusicVolume(newValue);
     AudioMixerConfigurator.Instance.Configure();
 }
예제 #4
0
 public void Configure()
 {
     m_Mixer.SetFloat(m_MixerVarMainVolume, GetVolumeInDecibels(ClientPrefs.GetMasterVolume()));
     m_Mixer.SetFloat(m_MixerVarMusicVolume, GetVolumeInDecibels(ClientPrefs.GetMusicVolume()));
 }
 void Start()
 {
     AudioListener.volume = ClientPrefs.GetMasterVolume();
     SceneManager.LoadScene("MainMenu");
 }