Table of Contents

LoginAsGuest

Methods
public static LoginOperation LoginAsGuest(CancellationToken cancellationToken = default)

Login to coherence Cloud using a guest account.

Parameters
Type Name Description
CancellationToken cancellationToken

Used to cancel the operation.

Returns
Type Description
LoginOperation

The status of the asynchronous login operation.

Remarks

LoginAsGuest(CancellationToken) will always return the same guest player account on the same device with the same project selected. A new GuestId is generated automatically the first time that LoginAsGuest(CancellationToken) is called with a particular project selected, and then cached and reused whenever LoginAsGuest(CancellationToken) is called again on the same device with the same project selected.

If you have a need to login with multiple different guest player accounts on the same device (for local multiplayer purposes, for example) use LoginAsGuest(LoginAsGuestOptions, CancellationToken).

'Guest Auth Enabled' must be ticked in Project Settings on your Online Dashboard for this authentication method to be usable.

Examples
using Coherence.Cloud;
using UnityEngine;

class LoginAsGuest : MonoBehaviour
{
    public PlayerAccount PlayerAccount { get; private set; }

    async void Start()
    {
        PlayerAccount = await CoherenceCloud.LoginAsGuest();
        Debug.Log($"Logged in as: {PlayerAccount}.");
    }
}
public static LoginOperation LoginAsGuest(LoginAsGuestOptions options, CancellationToken cancellationToken = default)

Login to coherence Cloud using a guest account.

Parameters
Type Name Description
LoginAsGuestOptions options

Options to use when logging in as a guest.

Providing custom options when logging in makes it possible to log in with multiple different guest player accounts on the same device. This could be useful for local multiplayer.

CancellationToken cancellationToken

Used to cancel the operation.

Returns
Type Description
LoginOperation

The status of the asynchronous login operation.

Remarks

A new GuestId is generated based on the provided unique id the first time that a playerAccount logs in as a guest to a particular project, and then cached and reused when the playerAccount logs in as a guest again to the same project on the same device using the same unique id.