Rooms
using Coherence.Cloud;
using Coherence.Toolkit;
using UnityEngine;
class CreateRoomExample : MonoBehaviour
{
async void Start()
{
// Wait until a player account has logged in to coherence Cloud.
// The CoherenceCloudLogin component can be used for this.
PlayerAccount playerAccount = await PlayerAccount.GetMainAsync();
// Fetch information about regions available in our Project.
var regionsService = playerAccount.Services.Regions;
var regions = await regionsService.FetchRegionsAsync();
// Create a new room in the first available region
var rooms = playerAccount.Services.Rooms;
var roomsService = rooms.GetRoomServiceForRegion(regions[0]);
var newRoom = await roomsService.CreateRoomAsync(RoomCreationOptions.Default);
// Join the room using the CoherenceBridge for this scene
if (CoherenceBridgeStore.TryGetBridge(gameObject.scene, out var bridge))
{
bridge.JoinRoom(newRoom);
}
}
}Last updated
Was this helpful?

