Monday, April 20, 2015

How to set up google play services with unity plugin for android



below notes are taken directly from https://github.com/playgameservices/play-games-plugin-for-unity  webpage. here I copied that article,  only making a quick access for myself. Also I wrote some extra notes. For full page please goto https://github.com/playgameservices/play-games-plugin-for-unity website.

how to google play services with unity plugin:

First of all, build your game and upload it to google play services.



1) goto https://github.com/playgameservices/play-games-plugin-for-unity and clone git repository, or download and unzip the zip file.
2) find latest unity package, it is under the current_build directory, its name is something like "current-build/GooglePlayGamesPluginForUnity-X.YY.ZZ.unitypackage"
3) open the Android SDK manager and verify that you have downloaded the Google Play Services package. The Android SDK manager is usually available in your SDK installation directory, under the "tools" subdirectory, and is called android (or android.exe on Windows). The Google Play Services package is available under the Extras folder. If it is not installed or is out of date, install or update it before proceeding.
4) set up the path to your Android SDK installation in Unity. This is located in the preferences menu, under the External Tools section.
5) configure your game's package name. To do this, click File | Build Settings, select the Android platform and click Player Settings to show Unity's Player Settings window. In that window, look for the Bundle Identifier setting under Other Settings. Enter your package name there (for example com.example.my.awesome.game).
6) click the Window |Google Play Games|Setup - Android setup menu item. This will display the Android setup screen, where you must input your Application ID (e.g. 12345678012). You will get your application id from google services page. click the Setup button.

Important: The application ID and package name settings must match exactly the values you used when setting up your project on the Developer Console.


=======================


How to manage with your code:
-------------------------------
The Google Play Games plugin implements a subset of Unity's social interface. The standard API calls can be accessed through the Social.Active object, which is a reference to an ISocialPlatform interface. The non-standard Google Play Games extensions can be accessed by casting the Social.Active object to the PlayGamesPlatform class, where the additional methods are available.



Sign in:
------------------------------------------
To sign in, call Social.localUser.Authenticate, which is part of the standard Unity social platform interface.

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // authenticate user:
    Social.localUser.Authenticate((bool success) => {
        // handle success or failure
    });
Authentication will show the required consent dialogs. If the user has already signed into the game in the past, this process will be silent and the user will not have to interact with any dialogs.

Note that you cannot make any games API calls (unlock achievements, post scores, etc) until you get a successful return value from Authenticate, so it is good practice to put up a standby screen until the callback is called, to make sure the user can't start playing the game until the authentication process completes.

WARNING: dont forget to set googleplayservices ad default social platform!!!

void Awake () {
// Select the Google Play Games platform as our social platform implementation
GooglePlayGames.PlayGamesPlatform.Activate();
}
how to check if an user is logged in or not?
public bool isLoggedInGooglePlayServices() {
bool sonuc = false;
if(Social.localUser.authenticated) {
sonuc = true;
}
return sonuc;
}


Sign out
------------------------------------------
To sign the user out, use the PlayGamesPlatform.SignOut method.

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;

    // sign out
    PlayGamesPlatform.Instance.SignOut();
After signing out, no further API calls can be made until the user authenticates again.




Revealing/Unlocking an Achievement
------------------------------------------
To unlock an achievement, use the Social.ReportProgress method with a progress value of 100.0f:

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // unlock achievement (achievement ID "Cfjewijawiu_QA")
    Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => {
      // handle success or failure
    });
Notice that according to the expected behavior of Social.ReportProgress, a progress of 0.0f means revealing the achievement and a progress of 100.0f means unlocking the achievement. Therefore, to reveal an achievement (that was previously hidden) without unlocking it, simply call Social.ReportProgress with a progress of 0.0f.


If your achievement is incremental, the Play Games implementation of Social.ReportProgress will try to behave as closely as possible to the expected behavior according to Unity's social API, but may not be exact. For this reason, we recommend that you do not use Social.ReportProgress for incremental achievements. Instead, use the PlayGamesPlatform.IncrementAchievement method, which is a Play Games extension.

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // increment achievement (achievement ID "Cfjewijawiu_QA") by 5 steps
    PlayGamesPlatform.Instance.IncrementAchievement(
        "Cfjewijawiu_QA", 5, (bool success) => {
            // handle success or failure
    });




Showing the Achievements UI
------------------------------------------
To show the built-in UI for all achievements, call Social.ShowAchievementsUI.

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // show achievements UI
    Social.ShowAchievementsUI();
This will show a standard UI appropriate for the look and feel of the platform (Android or iOS).




Posting a Score to a Leaderboard
------------------------------------------
To post a score to a leaderboard, call Social.ReportScore.

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // post score 12345 to leaderboard ID "Cfji293fjsie_QA")
    Social.ReportScore(12345, "Cfji293fjsie_QA", (bool success) => {
        // handle success or failure
    });
Note that the platform and the server will automatically discard scores that are lower than the player's existing high score, so you can submit scores freely without any checks to test whether or not the score is greater than the player's existing score.




To show the built-in UI for all leaderboards, call Social.ShowLeaderboardUI.
------------------------------------------
    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // show leaderboard UI
    Social.ShowLeaderboardUI();
If you wish to show a particular leaderboard instead of all leaderboards, you can pass a leaderboard ID to the method. This, however, is a Play Games extension, so the Social.Active object needs to be cast to a PlayGamesPlatform object first:

    using GooglePlayGames;
    using UnityEngine.SocialPlatforms;
    ...
    // show leaderboard UI
    PlayGamesPlatform.Instance.ShowLeaderboardUI("Cfji293fjsie_QA");



There are more data about cloud saving, reading from cloud or multiplayer issues on https://github.com/playgameservices/play-games-plugin-for-unity page. Since I dont need them yet, I did not gather data for them here.


Wednesday, March 11, 2015

How to Increase Unity Game Performance

I found a nice article giving some tips to optimize your game made with Unity.

for the audio performance here is a rule of thumb:

  • Short Clips – Native
  • Longer (or looping) clips – compressed in memory
  • Music – Stream from disc
  • Files which consistently cause CPU spikes – Decompress on load
sÄ°NCE only one hardware audio stream can be decompressed at a time. Follow the rules above to cause CPU spikes. 


also be sure to check the full article on:
http://www.paladinstudios.com/2012/07/30/4-ways-to-increase-performance-of-your-unity-game/








Tuesday, March 10, 2015

mobile device screen resolutions for unity editor aspect ratios

iphone 4 portrait: 640x960
iphone 4 landscape: 960x640
iphone 6 landscape: 1136x640



for publishing to google game play here are the resolutions ofr 7 " tablet and 10 " tablet screen shots:

To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

(from http://developer.android.com/guide/practices/screens_support.html#NewQualifiers)



well found a good site explaining all picture dimensions:
look at : http://xayin.com/thisisatest.html for more info.



more to come in time...

Monday, February 16, 2015

SOLVED: Error building Player: CommandInvokationFailure: Unable to retrieve device properties. Please make sure the Android SDK is installed and is properly configured in the Editor.

If you got an error saying "Error building Player: CommandInvokationFailure: Unable to retrieve device properties. Please make sure the Android SDK is installed and is properly configured in the Editor." well it is simple to solve that.

Just open windows Task Manager, and find "adb.exe".
 Right click on adb.exe and press "End Task" at the bottom of the window.

This will kill process adb.exe, and that is it.

Just  open unity and try to rebuild your game.

This happens especially if you are using a HTC mobile device.


If killing adb.exe process won't solve your problem, there is also a program  named as adbfix, but I did not tried it, try it at your own risk, here is the link:

http://visualgdb.com/adbfix/


anyway I have a HTC mobile device and with unity it sometimes says  "Error building Player: CommandInvokationFailure: Unable to retrieve device properties. Please make sure the Android SDK is installed and is properly configured in the Editor." When this happens I just reopen the task manager and kill adb.exe process then I will be able to build my game on my htc device.


Hope this helps someone.





Sunday, January 4, 2015

voxel art for games

voxel art is what minecrafting games look like. they are 3d but with pixels, like od style pixel arts but in 3d.

there are programs to do voxel art games like http://www.crossyroad.com/press game. They used voxelshop porgram called qubicle at the url : http://www.minddesk.com/.  You can also search for free options , a quick gogole search

1)  https://www.google.com.tr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=voxel+draw

2) https://www.google.com.tr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=best+voxel+drawing+tool

a free voxel art program : voxelshop :  http://blackflux.com/node/11

how to check google play services sha1 value - setting up google play services


find more info here: https://developers.google.com/games/services/console/enabling

here are some quck notes:
To get the release certificate fingerprint:
keytool -exportcert \
-alias <your-key-name> \
-keystore <path-to-production-keystore> \
-list -v
To get the debug certificate fingerprint:
keytool -exportcert \
-alias androiddebugkey \
-keystore <path-to-debug-keystore> \
-list -v


other links : 



https://developers.google.com/games/services/android/quickstart#step_3_modify_your_code


https://code.google.com/p/google-plus-platform/issues/detail?id=554


http://stackoverflow.com/questions/16580885/google-play-game-services-unable-to-sign-in

http://gmc.yoyogames.com/index.php?showtopic=581853&page=7