Last active
October 11, 2015 10:57
-
-
Save TORISOUP/932cafcc93cc2c06fd18 to your computer and use it in GitHub Desktop.
ログインボタンが押されたらログインする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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