Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Last active October 11, 2015 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TORISOUP/932cafcc93cc2c06fd18 to your computer and use it in GitHub Desktop.
Save TORISOUP/932cafcc93cc2c06fd18 to your computer and use it in GitHub Desktop.
ログインボタンが押されたらログインする
using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
using WebSocketSharp;
using ObservableNCMB;
public class LoginExample : MonoBehaviour
{
public String Id;
public Password;
[SerializeField] private Button loginButton;
private void Start()
{
//ログインボタンを押したらログインする
loginButton
.OnClickAsObservable()
.First()
.Do(_ => Debug.Log("ログイン開始"))
.SelectMany(_ => ObservableUserAuth.LoginAsync(Id, Password))
.OnErrorRetry((Exception ex) =>
{
//ログインに失敗したら1秒間無効化した後に再度Subscribe
Debug.LogError(ex);
}, TimeSpan.FromSeconds(1))
.Subscribe(x =>
{
Debug.Log("ログイン成功:" + x.UserName);
//シーン遷移処理とかここにかく
//
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment