-
Notifications
You must be signed in to change notification settings - Fork 2
GameService
VirtueSky edited this page Sep 8, 2024
·
4 revisions
- Game service is tools support sign in
With Apple Id
andGoogle Play Game Service
- Attach
GooglePlayGamesAuthentication
(for Android) andAppleAuthentication
(for iOS) to scene
- Open tab
GameService
inMagic Panel
to install library and add define symbols
- Demo script
public StatusLogin statusLogin = StatusLogin.NotLoggedIn;
public string serverCode = "";
private void OnEnable()
{
#if UNITY_ANDROID
GooglePlayGamesAuthentication.StatusLoginEvent += OnStatusLogin;
GooglePlayGamesAuthentication.ServerCodeEvent += OnServerCode;
#endif
#if UNITY_IOS
AppleAuthentication.StatusLoginEvent += OnStatusLogin;
AppleAuthentication.ServerCodeEvent += OnServerCode;
#endif
}
[Button]
public void Login()
{
#if UNITY_ANDROID
GooglePlayGamesAuthentication.Login();
#endif
#if UNITY_IOS
AppleAuthentication.Login();
#endif
}
private void OnServerCode(string obj)
{
serverCode = obj;
}
private void OnStatusLogin(StatusLogin obj)
{
statusLogin = obj;
}
- After calling
Login
,statusLogin
returns the result-
Successful
: Login successful andserverCode
has value -
Failed
: Login failed andserverCode
is empty
-