Authentication パッケージを使用してサインインする

前提条件: Unity Package Manager の Vivox パッケージを設定します

Vivox のサインインを最も簡単に管理する方法は、Unity Authentication パッケージを使用する方法です。

Authentication パッケージを使用するには、以下のステップを実行します。

  1. プロジェクトの manifest.json ファイルに com.unity.services.authentication のエントリーが含まれていることを確認します。

    詳細については、プロジェクトマニフェスト に関する Unity ドキュメントを参照してください。

  2. Vivox の機能を使用する前に実行するスクリプトに以下のコードスニペットを実装して、UnityServices を初期化します。

using System;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.Vivox;

async void Start()
{
    await UnityServices.InitializeAsync();
    await AuthenticationService.Instance.SignInAnonymouslyAsync();

    await VivoxService.Instance.InitializeAsync();
}
  1. VivoxService.Instance.LoginAsync(LoginOptions options = null) を使用してサインインします。

  2. チャンネルの種類に応じて、以下のコードサンプルのいずれかを使用して、チャンネルに参加します。

ポジショナルチャンネルまたはノンポジショナルチャンネルに参加する場合は、以下を使用します。

VivoxService.Instance.JoinGroupChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null), VivoxService.Instance.JoinPositionalChannelAsync(string channelName, ChatCapability chatCapability, Channel3DProperties positionalChannelProperties, ChannelOptions channelOptions = null)

エコーチャンネルに参加する場合は、以下を使用します。

VivoxService.Instance.JoinEchoChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null)