Worlds

After creating a World in the Dashboard, you can join it from your Unity Project using the CloudService.Worlds API combined with the CoherenceBridge.

Here is an example:

using Coherence.Cloud;
using Coherence.Toolkit;
using UnityEngine;

public class AsyncWorldsExample : MonoBehaviour
{
    async void Start()
    {
        // Wait until a player account has logged in to coherence Cloud.
        PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();

        // Fetch all available worlds from our Project
        var availableWorlds = await playerAccount.Services.Worlds.FetchWorldsAsync();

        // Try finding a coherence Bridge that has 'Player Account' set to 'Auto Login As Guest' or 'Main'
        // and have it join the first available world, if one exists
        if (availableWorlds.Count > 0 && CoherenceBridgeStore.TryGetBridge(playerAccount, out var bridge))
        {
            bridge.JoinWorld(availableWorlds[0]);
        }
    }
}

Last updated

Was this helpful?