GameKitJNA - Free Gamecentre code

Hi guys,

just thought I’d make my game center code available.

It sends scores, achievements, achievement progress, and also includes the default view for scores and achievements. Although the views will report latest scores/achievements across devices, I haven’t exposed any retrieval methods to get this data back to unity (wasn’t necessary for the project I built this for). If someone wants to add that feel free; no comments in the code but its pretty clear.

Code is released under MIT license so you can do whatever you want with it. Be great if you could stick a link back to http://jnamobile.com in your credits or web page but its not required. Also cool if you let me know if you are using it.

Although I may respond to posts to help you get this going there’s no guarantees. If you want that try Prime31’s great plugins.

Basically to get it going:

  • Copy the file from “CopyInToPluginsFolderInUnity” folder into plugins folder :slight_smile:
  • Build project (it will fail).
  • Copy the files from “CopyIntoXCodeProject” folder into build dir.
  • Add the GameCenter Framework to the XCode project.
  • Rebuild.
  • You can now call the gamekit functions from java or c# scripts.

EDIT: It’s awesome that I spelled game center wrong in the title too :slight_smile:

EDIT: Just a note that the MIT license requires you to include a copy of the MIT license in your software (you don’t have to release YOUR code under the license, just have it there noting that part of the software falls under that licesne). However if you have any issues with this just ask and I will waive that requirement for you.

709664–25644–$GameKitJNA.zip (8.29 KB)
728625–26477–$GameKitJNAView.zip (1.78 KB)

Thank you, that is great.

No probs, thanks for the positive comments :slight_smile:

It’s easy to do being that centre is the correct English spelling of the word, and center is the American-English spelling :slight_smile:

Forgot to mention you need to add the GameCenter Framework to your XCode project.

Hey thanks for the code! Hope this works! WIll try it

Argh, I forgot to add the view code to the zip file. Will update as soon as I get home.

Hey, thanks for the code, good starting point. Are you going to add the view class to the zip, deciding if I should make my own or not :slight_smile:

It’s ok I write my own, will post up in here when done if JNA doesn’t mind :slight_smile:

any video tutorial for this?

Sorry guys forgot about adding the view code as I hand’t had any questions regarding it (until now).

Attached here: 728625–26477–$GameKitJNAView.zip (1.78 KB)

Thanks for posting this!
B

bumpies

very nice, will see if i can get it working :slight_smile: x

How did you go jesusluvsyooh?

It really works, thanks man, really good job

i got a few errors XD testing on simulator, not the phone itself, and i believe i copied everything into the correct directories etc.

#endif // !(TARGET_IPHONE_SIMULATOR)
mono_dl_register_symbol(“_authenticateLocalPlayer”, (void*)_authenticateLocalPlayer);
mono_dl_register_symbol(“_isGameCenterAPIAvailable”, (void*)_isGameCenterAPIAvailable);
mono_dl_register_symbol(“_reportScore”, (void*)_reportScore);
mono_dl_register_symbol(“_reportAchievementComplete”, (void*)_reportAchievementComplete);
mono_dl_register_symbol(“_reportAchievementProgress”, (void*)_reportAchievementProgress);
mono_dl_register_symbol(“_reportCumulativeAchievementProgress”, (void*)_reportCumulativeAchievementProgress);
mono_dl_register_symbol(“_showAchievements”, (void*)_showAchievements);
mono_dl_register_symbol(“_showScores”, (void*)_showScores);
mono_dl_register_symbol(“_GetAngularVelocity”, (void*)_GetAngularVelocity);
mono_dl_register_symbol(“_SetAngularVelocity”, (void*)_SetAngularVelocity);
mono_dl_register_symbol(“_GetRotation”, (void*)_GetRotation);
mono_dl_register_symbol(“_SetRotation”, (void*)_SetRotation);
mono_dl_register_symbol(“_SetHighestSpinSpeed”, (void*)_SetHighestSpinSpeed);
mono_dl_register_symbol(“_GetHighestSpinSpeed”, (void*)_GetHighestSpinSpeed);
mono_dl_register_symbol(“_GetAngularDrag”, (void*)_GetAngularDrag);
mono_dl_register_symbol(“_GetAutoRotate”, (void*)_GetAutoRotate);
mono_dl_register_symbol(“_ActivateUI”, (void*)_ActivateUI);
mono_dl_register_symbol(“_DeactivateUI”, (void*)_DeactivateUI);
}

Put gamekitjnabinding.cs into Plugins folder in unity, copied gamekitjnabinding.m, gamekitjna.h and gamekitjna.mm into xcode main project directory, then dragged in gamekitjnaview.m and.h into Xcode project main directory.
Ive got game centre activated for the version of the game I’m working on, but still get those errors above

okay when running straight to the phone i don’t get the errors, but the game centre doesn’t work :confused:
i could take print screens of anything you want to check, just let me know

I must admit, I never use the simulator… I was under the impression it didn’t work for Unity stuff …

Did you add the game centre framework into the project (step 4)?

What’s the console say in terms of debug messages?

Have you entered “developer mode” Game Center (as per instructions in Apples game centre page)?

Are you calling authenticate local player when your app starts:

function Start() {
	GameKitJNABinding.authenticateLocalPlayer();	
}

Is your phone of the correct OS version?

i will try it when i get home and let you know how it goes, kudos for helping and replying btw :slight_smile:

Edit: ITS ALIVVEEE!

i tinkered with a few settings but believe it was the

thanks for the help, i’l remember you every time i add game centre to a game! :slight_smile:

Thanks, good to hear mate. Let me know when you release :slight_smile: