Gamecenter does not work on AppleTV
Greetings. We use the Game Center in our game. In the IOS everything works. On AppleTB Leaderboards are shown for the first time, but when the second leaderboard call is played, the game hangs with an error "We failed to present Game Center dashboard extension."
For anyone stuck on this, we have heard that the problem is caused by not having "Apple TV Dashboard Images" set up. We have not yet confirmed that this works, but are trying it out now.
I found a reference to this solution on this SO question:
https://stackoverflow.com/questions/34406727/game-center-in-tvos-not-showing-up
Answer by joe_nk · Sep 18, 2019 at 11:03 PM
The issue appears to be a problem with the Game Center View Controller on tvOS not being able to cope with the view not having a 'Dashboard Image' You can fix this by adding one in the xcode project manually inside the UnityImages.xcassets folder:
After adding this you'll probably get a build error like this:
On-Demand Resources is enabled (ENABLE_ON_DEMAND_RESOURCES = YES),
but the PRODUCT_BUNDLE_IDENTIFIER build setting is empty
This means you need to set your PRODUCT_BUNDLE_IDENTIFIER in the project build settings - Unity doesn't do this for you.
We were able to automate both of these steps with the following script:
using System;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using Newtonsoft.Json;
namespace BuildAutomation {
#if UNITY_TVOS
public class BuildScript {
[Serializable]
class XCodeImageSet {
[Serializable]
public class Info {
public int version = 0;
public string author = null;
}
[Serializable]
public class Image {
public string idiom = null;
public string filename = null;
public string scale = null;
}
public Info info = null;
public Image[] images = null;
}
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) {
string projPath = PBXProject.GetPBXProjectPath(path);
var proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
var target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
proj.SetBuildProperty(target, "PRODUCT_BUNDLE_IDENTIFIER", UnityEngine.Application.identifier);
File.WriteAllText(projPath, proj.WriteToString());
const string dbImageName = "tvOs_DashboardArtwork";
const string dbImageFolder = "DashboardImage";
string dbImagePath = $"{path}/UnityImages.xcassets/{dbImageFolder}.gcdashboardimage/{dbImageFolder}.imageset/";
Directory.CreateDirectory(dbImagePath);
string[] imageAssetGuids = AssetDatabase.FindAssets(dbImageName);
XCodeImageSet imageSet = new XCodeImageSet {
info = new XCodeImageSet.Info {
version = 1,
author = "com.yourcompany",
},
images = new XCodeImageSet.Image[imageAssetGuids.Length]
};
for (int i = 0; i < imageAssetGuids.Length; ++i) {
string fileGuid = imageAssetGuids[i];
string filePath = AssetDatabase.GUIDToAssetPath(fileGuid);
string fileName = Path.GetFileName(filePath);
imageSet.images[i] = new XCodeImageSet.Image{
idiom = "tv",
filename = fileName,
scale = fileName.Contains("@2x") ? "2x" : "1x",
};
File.Copy(filePath, dbImagePath + fileName);
}
File.WriteAllText(
dbImagePath + "Contents.json",
JsonConvert.SerializeObject(imageSet)
);
}
}
#endif
}
If using this script, just make sure you have the images named tvOs_DashboardArtwork.png and tvOs_DashboardArtwork_@2x.png somewhere in your Assets folder. Guidelines for the image dimensions can be found here
Hope this helps others having this issue!
Thanks for sharing this, I've followed this steps before - and it will open twice but there is a long (waiting for a timeout) Is there a specific na$$anonymous$$g convention, or rule for the actual images - when adding them manually to xcode I don't get any errors. Thank you!
We're not seeing this issue but we're not using Game Center leaderboards, which I think you are? So there could be a separate issue there.. We just added the 'Apple TV Dashboard Image' (pngs - one at 923x150 and another @2x). Guidelines for these images can be found here: https://developer.apple.com/design/human-interface-guidelines/tvos/icons-and-images/game-center-images/
I'm only using achievements. I just added two transparent images in the right dimensions
Hey! Thank you so much for sharing this solution.
Sorry i came late to the party, but implementing this I've stumbled into a couple discoveries that might be helpful regarding the code.
As Newtonsoft requires you to add an additional plugin, I've been able to get the json serialized using the UnityEngine's JsonUtility.ToJson() function. ( so 'using UnityEngine' is required for that function)
As this code requires Editor data, you'll have to add this script to an 'Editor' folder, for it to be processed after building and being able to access Editor values. $$anonymous$$ore info on Special Folders can be found here.
I'm not sure if this is obvious, but I just wanted to point that out.
Cheers!
Answer by leenk · Sep 04, 2019 at 09:17 PM
@o___O @paatz04 - Did anyone manage to find an answer to this issue? We're in a bit of an emergency situation over this right now, and any tips or advice would be a lifesaver! Thanks!
In XCode, the game freezes for a few seconds, and then we see the error:
"We failed to present Game Center dashboard extension"
Your answer
![](https://koobas.hobune.stream/wayback/20220612163158im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can i Implement iOS GameCenter leaderboards in my game? 1 Answer
How to load a specific Game Center leaderboard? 1 Answer
GameCenter Leaderboard Reporting Scores 1 Answer
How to get user names in google play game services leaderboard 4 Answers
Maddening error when trying to add Google Leaderboards 0 Answers