Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

ILocalUser.Authenticate

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public function Authenticate(callback: Action<bool>): void;
public void Authenticate(Action<bool> callback);

Parámetros

callback Callback that is called whenever the authentication operation is finished.

Descripción

Authenticate the local user to the current active Social API implementation and fetch their profile data.

This should be done before any other calls into the API. Depending on the platform this might trigger a potentially blocking dialog for providing login details.

On certain platforms the callback may not be invoked after the second and subsequent calls of the function during a single run of the program, provided that the user or OS cancelled the first attempt to authenticate.


        
using UnityEngine;
using UnityEngine.SocialPlatforms;
using System.Collections;

public class Example : MonoBehaviour { void Start() { Social.localUser.Authenticate (success => { if (success) { Debug.Log ("Authentication successful"); string userInfo = "Username: " + Social.localUser.userName + "\nUser ID: " + Social.localUser.id + "\nIsUnderage: " + Social.localUser.underage; Debug.Log (userInfo); } else Debug.Log ("Authentication failed"); }); } }