Google Login Access Unity

Source: Internet
Author: User

Recent projects to access Google's login. Tell me about the hole you've stepped on.

The first time access to Google's login SDK, online search for half a day. Find yourself searching for the wrong keywords. I've been searching the internet for Google sign-in. The results have been searched for all of the articles are Android access methods.

As a result I exported Android projects from Unity and followed the online approach. it turned out to be impossible!

Google sign-up for unity access in the next page

Unity access to Google Login website access documents (not FQ can also be opened): Https://github.com/playgameservices/play-games-plugin-for-unity

Click Current-build to download Googleplaygamesplugin-**.unitypackage

You can import the Unity project by double clicking on the downloaded file.

Toggle Unity Project for Android platform (File->build Setting->android->switch platform)

Add down click on the Window->google Play games->setup->android Setup ..., (operation as) in the Unity menu

You can open the following interface:

The next step is to fill in the 2 red-framed sections.

The first red box that you fill in is actually the achievement information for the app you're applying for in Google.

The second red box (that is, client ID) is filled in with the customer ID of the Web client (Web client) in the Project OAuth 2.0 client ID in Google APIs (this is especially important to note that the ID of the Web client must be filled out, otherwise it will not work)

When you are finished, click the Setup button to complete the setup.

The next step is to write the login code in unity.

Staticplaygamesclientconfiguration config =NewPlaygamesclientconfiguration.builder (). Enablesavedgames (). Requestemail (). Requestserverauthcode (false)            . Requestidtoken (). Build (); Public voidSignIn () {playgamesplatform.initializeinstance (config); Playgamesplatform.debuglogenabled=true;        Playgamesplatform.activate (); Social.Active.localUser.Authenticate ((BOOLSuccess) ={            if(Success) {Debug.Log ("UserName:"+((Playgameslocaluser) social.localuser). UserName); Debug.Log ("Login Successful"); Emailstr=((Playgameslocaluser) social.localuser).                Email; Tokenstr=((Playgameslocaluser) social.localuser).            Getidtoken (); } Else{Debug.Log ("Logon Failure");            }        }); }

Google Login Access Unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.