[FREE] Game Center Access Point for iOS

Hi all,

My current game is an iPhone / iPad app and as it was targeting iOS 14 (due to being developed on a DTK) I thought I’d try to include support for the new GKAccessPoint.

I’ve started creating a new plugin (my first foray into Objective-C).

It’s free of charge as I don’t see any real value in selling it, and I was hoping someone(s) would be able to help test.

It should be as simple as importing the attached unity package, then in your C# script add:

using GameCenterAccessPoint;

To show the access point icon, from one of your scripts call:

AccessPoint.ShowAccessPoint(true, GKAccessPointLocation.GKAccessPointLocationTopTrailing);

This will display the highlights banner first, followed by the user icon in the top left corner.

If you don’t want the highlights banner:

    AccessPoint.ShowHighlights(false); //true or false depending on if you want to display highlights banner first
AccessPoint.ShowAccessPoint(true, GKAccessPointLocation.GKAccessPointLocationTopTrailing);

Available positions are:

GKAccessPointLocationTopLeading,  //top left
GKAccessPointLocationTopTrailing, //top right
GKAccessPointLocationBottomLeading, //bottom left
GKAccessPointLocationBottomTrailing //bottom righr

Once the access point is visible, you can get the rect that the access point occupies:

CGRect _rect = AccessPoint.GetAccessPointFrameInScreenCoord();
print($"Width: {_rect.size.width}");
print($"Origin X: {_rect.origin.x}");

I will try to add some more functionality, but any feedback would be appreciated.

*update 1 - I’ve added the ability to manually trigger the Game Center popover:

AccessPoint.Trigger();
  • note - it does require iOS 14 / MacOs 11

Access Point visible (top right)

Highlights banner

Game Center popover open

6201110–680597–GameCenterAccessPoint.unitypackage (3.04 KB)

These are untested but should be right. Would be handy to wrap any in compiler checks if you’re wanting to add the new API code but still compiling for iOS13 in the interim.

#include <Availability.h>
#include <TargetConditionals.h>

#if defined(__IPHONE_14_0) && TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_14_0
#define IOS_14_OR_NEWER
#endif

#if defined(__TVOS_14_0) && TARGET_OS_TV && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_14_0
#define TVOS_14_OR_NEWER
#endif

#if defined(__MAC_11_0) && TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0
#define MACOS_11_OR_NEWER
#endif

#if IOS_14_OR_NEWER
// use some iOS14 only API
#endif

1 Like

Brilliant, thank you. I’ll do so

That worked, it runs against ios14 and 13. Thank you @jason_yak

1 Like

Can you share the updated version ? :slight_smile:

I sure can, I am just testing something then I’ll upload it.

1 Like

Did you get it working? :slight_smile:

1 Like

Hi,

I’ve not had a proper chance to test due to some other commitments, here is the latest build though, if you have time to test it that would be great.

Regards

6254358–689652–GameCenterAccessPoint.unitypackage (3.08 KB)

Will give it a go, awesome work and thanks for sharing!

1 Like

I’ve had a few issues hiding the Access Point once it’s been shown ( I want it in the menu but not the main game screen ). Seems several people are having the same issue, so once I figure it out I will upload a new version

I’ve made a few updates:

  • Tidied up code
  • Sorted issue with access point always showing in top right corder
  • Fixed issue with macros not picking up wrong IOS version
  • Fixed code to hide access point

I hope you can make use, and let me know bugs

6328983–702312–GameCenterAccessPoint.unitypackage (2.92 KB)

2 Likes

Is GetAccessPointFrameInScreenCoord working? It seems all of its values return zero.

Since the best I could guess was that something was going wrong when trying to mirror the CGRect in C# land, I just made it output 4 floats instead.

    void _getAccessPointFrameInScreenCoord(float* x, float* y, float* w, float* h)
    {
        CGRect area = [GameCenterAccessPoint getAccessPointFrameInScreenCoord];
        CGRect boundsarea = [GameCenterAccessPoint getBounds];
        *x = area.origin.x / boundsarea.size.width;
        *y = area.origin.y / boundsarea.size.height;
        *w = area.size.width / boundsarea.size.width;
        *h = area.size.height / boundsarea.size.height;
    }

(I’m also dividing my bounds width and height to more easily convert to viewport coords in Unity).

Now the next problem is that isVisible doesn’t seem to work (always returns false) and I’m unsure what the problem is.

Just an update in case someone else goes through this, it seems isVisible is buggy and it may even be Apple’s fault, so we ended up checking if the w value in _getAccessPointFrameInScreenCoord is > 0 instead, and it seems to work pretty well.

Is there support for arm64? I tried to add it to project but no luck…
Is there final version of it available?

Apologies, been absent for some personal reasons. I’ve not had chance to work on my game, or on this project but will be updating soon.

if you still need help, please drop me a message

Hey everyone! Thanks for all the great work on this @gavinb80 ! Using this for my game on iOS15 - noticed there were some issues with the triggers (Xcode would not compile the game unless I commented out lines 50,51,59,60 and 67 in GameCenterAccessPoint.cs)

One question I have - the current setup defaults to what looks like the Player profile - how would I go about changing this to showing for example a single leaderboard (as outlined here: Displaying the Game Center dashboard | Apple Developer Documentation )

Thanks!