Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mathieu-b/5f442cba5698946b4db3f2b323b2cf97 to your computer and use it in GitHub Desktop.
Save mathieu-b/5f442cba5698946b4db3f2b323b2cf97 to your computer and use it in GitHub Desktop.
When Unity3D stubbornly resets / forgets your Android app package name...
// Put this script in your "Editor" scripts folder ;)
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
class SetAppBundleIdentifierContinuously
{
static readonly string bundleIdentifier = "com.my.package.name";
static readonly BuildTargetGroup[] buildTargetGroups =
{
BuildTargetGroup.Standalone,
BuildTargetGroup.Android,
BuildTargetGroup.iOS
};
static SetAppBundleIdentifierContinuously ()
{
EditorApplication.update += Update;
}
static void Update ()
{
SetApplicationIdentifierForBuildTargetGroups(bundleIdentifier);
if (hello_count < 0)
{
Debug.Log("Hello Unity...");
hello_count = 200;
}
hello_count--;
}
static void SetApplicationIdentifierForBuildTargetGroups(string application_identifier)
{
foreach (var build_target_group in buildTargetGroups)
{
//Debug.Log("Setting Application identifier '" + application_identifier + "' for build target group " + build_target_group);
PlayerSettings.SetApplicationIdentifier(build_target_group, application_identifier);
}
}
static int hello_count;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment