Skip to content

GameService

VirtueSky edited this page Sep 8, 2024 · 4 revisions

What

  • Game service is tools support sign in With Apple Id and Google Play Game Service

Use

  • Attach GooglePlayGamesAuthentication (for Android) and AppleAuthentication (for iOS) to scene

Screenshot 2024-07-29 175700

  • Open tab GameService in Magic Panel to install library and add define symbols

Screenshot 2024-07-29 175748

  • 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 and serverCode has value
    • Failed: Login failed and serverCode is empty
Clone this wiki locally