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.”

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:

[146336-dashboardimage.jpg*_|146336]

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.

[146337-screenshot-2019-09-19-at-104323-am.png*_|146337]

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*;*
  •  		string filePath = AssetDatabase.GUIDToAssetPath(fileGuid);*
    
  •  		string fileName = Path.GetFileName(filePath);*
    

_ imageSet.images = 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][3]
Hope this helps others having this issue!
_*
_*
_*[3]: https://developer.apple.com/design/human-interface-guidelines/tvos/icons-and-images/game-center-images/*_

@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!