Vivox Unity SDK 16.0.0 업그레이드 가이드
Upgrade from previous Vivox versions to version 16.0.0.
읽는 시간 4분최근 업데이트: 19일 전
이 가이드는 Vivox Unity SDK 버전 16.0.0으로 업그레이드하는 방법에 대한 세부 정보를 제공하고 두 SDK 버전 간의 차이점을 중점적으로 다룹니다.
버전 16.0.0에는 단순화된 기능이 도입되었으며 다음과 관련된 영역에서도 변경이 필요합니다.
- SDK 초기화
- 로그인/로그아웃
- 플레이어 차단
- 채널에 연결
- 채널 참가자 관리
- 오디오 디바이스 관리
- 액티브 디바이스 설정
- 디바이스 게인/음량 설정
- 디바이스 음소거
SDK 설정 및 초기화
Vivox API에 액세스하려면using VivoxUnity;using Unity.Services.Vivox;Authentication 사용
Unity Authentication 패키지를 사용하는 경우 다음 예제와 같이
await UnityServices.InitializeAsync()await AuthenticationService.Instance.SignInAnonymously()await VivoxService.Instance.InitializeAsync()async void InitializeAsync(){ await UnityServices.InitializeAsync(); await AuthenticationService.Instance.SignInAnonymouslyAsync(); await VivoxService.Instance.InitializeAsync();}
AuthenticationService.InstanceAuthenticationService
다음은 AuthenticationService 패키지가 없고 Test Mode가 활성화된 초기화 설정을 보여 주는 예제입니다.
async void InitializeAsync(){ await UnityServices.InitializeAsync(); await VivoxService.Instance.InitializeAsync();}
Vivox 개발자 포털 인증정보 사용
레거시 Vivox 개발자 포털 인증정보가 있는 경우InitializationOptionsVivoxService.Instance.InitializeAsyncasync void InitializeAsync(){ InitializationOptions options = new InitalizationOptions(); // _key can be excluded from SetVivoxCredentials if an implementation of IVivoxTokenProvider has been provided to the SDK. options.SetVivoxCredentials(_server, _domain, _issuer, _key); await UnityServices.InitializeAsync(options); await VivoxService.Instance.InitializeAsync();}
로그인 라이프사이클 변경 사항
ILoginSession.BeginLoginVivoxService.Instance.LoginAsync(LoginOptions options = null)LoginOptions- DisplayName
- 텍스트 투 스피치 활성화
- 새 채널에 참여할 때 자동 채널 전송 교환 비활성화
- 로그인 시 현재 플레이어에 대해 차단(교차 음소거)할 PlayerID 목록 캐싱
- SDK가 참가자 업데이트 이벤트를 수신하는 속도 설정
Vivox 서비스 로그아웃을 위해async void LoginToVivoxAsync(List<string> blockedList, string displayName){ LoginOptions options = new LoginOptions(); options.DisplayName = displayName; options.BlockedUserList = blockedList; await VivoxService.Instance.LoginAsync(options);}
ILoginSession.Logout()VivoxService.Instance.LogoutAsyncLoginState.LoggedInLoginState.LoggedOutLoginSession.PropertyChangedVivoxService.Instance.LoggedInVivoxService.Instance.LoggedOutvoid Start(){ VivoxService.Instance.LoggedIn += OnUserLoggedIn; VivoxService.Instance.LoggedOut += OnUserLoggedOut;}void OnDestroy(){ //Cleanup events if the GameObject is destroyed to prevent unexpected behavior. VivoxService.Instance.LoggedIn -= OnUserLoggedIn; VivoxService.Instance.LoggedOut -= OnUserLoggedOut;}void OnUserLoggedIn(){ Debug.Log("The user has successfully logged in"); // Other logic such as attempting a default channel join or changing the state of voice UIs to indicate the character is logged in can be done here.}void OnUserLoggedOut(){ Debug.Log("The user has logged out"); // The LoggedOut event will fire after a VivoxService.Instance.LogoutAsync call has been completed successfully // or after an internet disruption has caused Automatic Connection Recovery to declare the attempted recovery a failure.}
플레이어 차단
ILoginSession.SetCrossMutedCommunicationsVivoxServince.Instance.BlockPlayerAsync(string playerId)VivoxService.Instance.UnblockPlayerAsync(string playerId)AccountIdplayerId채널 라이프사이클 변경 사항
채널 참여 및 나가기
ChannelSession.BeginConnectJoinGroupChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null);JoinPositionalChannelAsync(string channelName, ChatCapability chatCapability, Channel3DProperties positionalChannelProperties, ChannelOptions channelOptions = null);JoinEchoChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null);
ChannelSession.Disconnect()- : 특정 채널 나가기
VivoxService.Instance.LeaveChannelAsync(string channelName) - : 모든 활성화된 채널 나가기 (언제든지 단일 채널만 참여하는 경우 이 메서드를 사용하는 것이 좋습니다.)
VivoxService.Instance.LeaveAllChannelsAsync()
ILoginSession.ChannelSessionsVivoxService.Instance.ActiveChannelsVivoxService.Instance.ActiveChannelsVivoxParticipantsAudioStateTextStateVivoxService.Instance.ChannelJoinedVivoxService.Instance.ChannelLeftVivoxService.Instance.ChannelJoinedVivoxService.Instance.ChannelLeftvoid BindToChannelActions(){ //Connecting/Disconnecting channel actions can be done upon VivoxService.Instance.LoggedIn and LoggedOut events being fired, respectively, //for basic lifecycle control VivoxService.Instance.ChannelJoined += OnChannelJoined; VivoxService.Instance.ChannelLeft += OnChannelLeft;}void UnbindChannelActions(){ VivoxService.Instance.ChannelJoined -= OnChannelJoined; VivoxService.Instance.ChannelLeft -= OnChannelLeft;}void OnChannelJoined(string channelName){ //The channel with name channelName has been successfully joined, and any UI updates should be done for it //Additionally, if multiple channels are being handled, keeping track of the channelName and knowing which channel is for which purpose should be done //on the side of the implementation based on this event.}void OnChannelLeft(string channelName){ //The channel with name channelName has been successfully left, and any UI updates should be done for it //This also means that the channelName can likely be safely lost, although if the channelName is specific and might be rejoined, //it should be held on to by the implementation.}
채널 전송
기본적으로 채널 전송(말하는 채널)은 가장 최근에 참여한 채널로 전환됩니다.LoginOptions.DisableAutomaticChannelTransmissionSwapVivoxService.Instance.LoginAsyncVivoxService.Instance.SetChannelTransmissionModeAsync(TransmissionMode transmissionMode, string channelName = null)채널 참가자 관리
VivoxParticipant가 ChannelParticipant를 대체했습니다. 올바른 키(채널 이름)를 사용하는 경우VivoxService.Instance.ActiveChannelsVivoxService.Instance.ParticipantAddedToChannelVivoxServince.Instance.ParticipantRemovedFromChannelvoid BindToParticipantEvents(){ //These events can be connected at the same time as the channel events from the previous sections for convenience purposes VivoxService.Instance.ParticipantAddedToChannel += OnParticipantAdded; VivoxService.Instance.ParticipantRemovedFromChannel += OnParticipantRemoved;}void UnbindParticipantEvents(){ VivoxService.Instance.ParticipantAddedToChannel -= OnParticipantAdded; VivoxService.Instance.ParticipantRemovedFromChannel -=OnParticipantRemoved;}void OnParticipantAdded(VivoxParticipant participant){ // Use VivoxParticipant to establish some UI element tied to that specific VivoxParticipant, which can then be used to control things such as muting // volume, and blocking, along with UI that can track certain states - such as whether the player is currently muted or is currently speaking.}void OnParticipantRemoved(VivoxParticipant participant){ // At this point, any UI created to display information about this VivoxParticipant can be safely disposed of.}
VivoxParticipant 오브젝트
VivoxParticipant- , 참가자가 로컬 플레이어를 나타내는지 여부를 알려 줍니다.
VivoxParticipant.IsSelf - , 참가자의 오디오 에너지가 Vivox SDK에서 스피치로 간주되는 임곗값을 통과했는지 여부를 알려 줍니다.
VivoxParticipant.SpeechDetected
ParticipantMuteStateChangedParticipantSpeechDetectedParticipantAudioEnergyChanged
다음 샘플 클래스는 ChatChannelSample에 있는 RosterItem의 단순화된 버전입니다.
public class RosterItem : MonoBehaviour{ public VivoxParticipant Participant; public Text PlayerNameText; public void SetupRosterItem(VivoxParticipant participant) { Participant = participant; PlayerNameText.text = Participant.DisplayName; Participant.ParticipantMuteStateChanged += OnMuteStateChanged; Participant.ParticipantSpeechDetected += OnSpeechDetected; } void OnMuteStateChanged() { if(Participant.IsMuted) { //Participant has been muted } else { //Participant has been unmuted } } void OnSpeechDetected() { //Participant AudioEnergy has exceeded the value required to be considered speech }}
채널 참가자 음소거
VivoxParticipant.MutePlayerLocally()VivoxParticipant.UnmutePlayerLocally()오디오 디바이스 관리
더 이상 클라이언트 오브젝트를 활용하여 디바이스 관리를 수행할 수 없습니다. 이제VivoxService.Instance로컬 플레이어 음소거
로컬에서 스스로 음소거하기는 함수VivoxService.Instance.MuteInputDevice()VivoxService.Instance.UnmuteInputDevice()입력/출력 디바이스 음량 조정
이제VivoxService.Instance.SetInputDeviceVolume(int value)VivoxService.Instance.SetOutputDeviceVolume(int value)액티브 입력/출력 디바이스 변경
액티브 입력 디바이스나 출력 디바이스는VivoxService.Instance.SetActiveOutputDeviceAsync(VivoxOutputDevice device)VivoxService.Instance.SetActiveInputDeviceAsync(VivoxInputDevice device)VivoxInputDevicesVivoxOutputDevicesVivoxService.Instance.AvailableInputDevicesVivoxService.Instance.AvailableOututDevicesusing System.Linq;using Unity.Services.Vivox;using UnityEngine;using UnityEngine.UI;public class AudioDeviceSettings : MonoBehaviour{ public Dropdown InputDeviceDropdown; private void Start() { VivoxService.Instance.AvailableInputDevicesChanged += RefreshInputDeviceList; InputDeviceDropdown.onValueChanged.AddListener((i) => { InputDeviceValueChanged(i); }); } void OnEnable() { RefreshInputDeviceList(); } void OnDestroy() { // Unbind all UI actions InputDeviceDropdown.onValueChanged.RemoveAllListeners(); VivoxService.Instance.AvailableInputDevicesChanged -= RefreshInputDeviceList; } private void RefreshInputDeviceList() { InputDeviceDropdown.Hide(); InputDeviceDropdown.ClearOptions(); InputDeviceDropdown.options.AddRange(VivoxService.Instance.AvailableInputDevices.Select(v => new Dropdown.OptionData() { text = v.DeviceName })); InputDeviceDropdown.SetValueWithoutNotify(InputDeviceDropdown.options.FindIndex(option => option.text == VivoxService.Instance.ActiveInputDevice.DeviceName)); InputDeviceDropdown.RefreshShownValue(); } void InputDeviceValueChanged(int index) { VivoxService.Instance.SetActiveInputDeviceAsync(VivoxService.Instance.AvailableInputDevices.Where(device => device.DeviceName == InputDeviceDropdown.options[index].text).First()); }}