private void AndroidUtilGUI() { this.showAndroidUtils = EditorGUILayout.Foldout(this.showAndroidUtils, "Android Build Facebook Settings"); if (this.showAndroidUtils) { if (!FacebookAndroidUtil.SetupProperly) { var msg = "Your Android setup is not right. Check the documentation."; switch (FacebookAndroidUtil.SetupError) { case FacebookAndroidUtil.ErrorNoSDK: msg = "You don't have the Android SDK setup! Go to " + (Application.platform == RuntimePlatform.OSXEditor ? "Unity" : "Edit") + "->Preferences... and set your Android SDK Location under External Tools"; break; case FacebookAndroidUtil.ErrorNoKeystore: msg = "Your android debug keystore file is missing! You can create new one by creating and building empty Android project in Ecplise."; break; case FacebookAndroidUtil.ErrorNoKeytool: msg = "Keytool not found. Make sure that Java is installed, and that Java tools are in your path."; break; case FacebookAndroidUtil.ErrorNoOpenSSL: msg = "OpenSSL not found. Make sure that OpenSSL is installed, and that it is in your path."; break; case FacebookAndroidUtil.ErrorKeytoolError: msg = "Unkown error while getting Debug Android Key Hash."; break; } EditorGUILayout.HelpBox(msg, MessageType.Warning); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(this.androidKeystorePathLabel, GUILayout.Width(180), GUILayout.Height(16)); FacebookSettings.AndroidKeystorePath = EditorGUILayout.TextField(FacebookSettings.AndroidKeystorePath); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField( "Copy and Paste these into your \"Native Android App\" Settings on developers.facebook.com/apps"); this.SelectableLabelField(this.packageNameLabel, Utility.GetApplicationIdentifier()); this.SelectableLabelField(this.classNameLabel, ManifestMod.DeepLinkingActivityName); this.SelectableLabelField(this.debugAndroidKeyLabel, FacebookAndroidUtil.DebugKeyHash); if (GUILayout.Button("Regenerate Android Manifest")) { ManifestMod.GenerateManifest(); } } EditorGUILayout.Space(); }
// Exporting the *.unityPackage for Asset store public static string ExportPackage() { Debug.Log("Exporting Facebook Unity Package..."); string path = OutputPath; try { if (!File.Exists(Path.Combine(Application.dataPath, "Temp"))) { AssetDatabase.CreateFolder("Assets", "Temp"); } AssetDatabase.MoveAsset(SDKPath + "Resources/FacebookSettings.asset", "Assets/Temp/FacebookSettings.asset"); AssetDatabase.DeleteAsset(PluginsPath + "Android/AndroidManifest.xml"); AssetDatabase.DeleteAsset(PluginsPath + "Android/AndroidManifest.xml.meta"); string[] facebookFiles = (string[])Directory.GetFiles(FacebookPath, "*.*", SearchOption.TopDirectoryOnly); string[] sdkFiles = (string[])Directory.GetFiles(SDKPath, "*.*", SearchOption.AllDirectories); string[] exampleFiles = (string[])Directory.GetFiles(ExamplesPath, "*.*", SearchOption.AllDirectories); string[] pluginsFiles = (string[])Directory.GetFiles(PluginsPath, "*.*", SearchOption.AllDirectories); string[] playServicesResolverFiles = (string[])Directory.GetFiles(PlayServicesResolverPath, "*.*", SearchOption.AllDirectories); string[] files = new string[facebookFiles.Length + sdkFiles.Length + exampleFiles.Length + pluginsFiles.Length + playServicesResolverFiles.Length]; facebookFiles.CopyTo(files, 0); sdkFiles.CopyTo(files, facebookFiles.Length); exampleFiles.CopyTo(files, sdkFiles.Length + facebookFiles.Length); pluginsFiles.CopyTo(files, sdkFiles.Length + facebookFiles.Length + exampleFiles.Length); playServicesResolverFiles.CopyTo(files, sdkFiles.Length + facebookFiles.Length + exampleFiles.Length + pluginsFiles.Length); AssetDatabase.ExportPackage( files, path, ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Recurse); } finally { // Move files back no matter what AssetDatabase.MoveAsset("Assets/Temp/FacebookSettings.asset", SDKPath + "Resources/FacebookSettings.asset"); AssetDatabase.DeleteAsset("Assets/Temp"); // regenerate the manifest ManifestMod.GenerateManifest(); } Debug.Log("Finished exporting!"); return(path); }
private void AppLinksUtilGUI() { this.showAppLinksSettings = EditorGUILayout.Foldout(this.showAppLinksSettings, "App Links Settings"); if (this.showAppLinksSettings) { for (int i = 0; i < FacebookSettings.AppLinkSchemes.Count; ++i) { EditorGUILayout.LabelField(string.Format("App Link Schemes for '{0}'", FacebookSettings.AppLabels[i])); List <string> currentAppLinkSchemes = FacebookSettings.AppLinkSchemes[i].Schemes; for (int j = 0; j < currentAppLinkSchemes.Count; ++j) { GUI.changed = false; string scheme = EditorGUILayout.TextField(currentAppLinkSchemes[j]); if (scheme != currentAppLinkSchemes[j]) { currentAppLinkSchemes[j] = scheme; this.SettingsChanged(); } if (GUI.changed) { ManifestMod.GenerateManifest(); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add a Scheme")) { FacebookSettings.AppLinkSchemes[i].Schemes.Add(string.Empty); this.SettingsChanged(); } if (currentAppLinkSchemes.Count > 0) { if (GUILayout.Button("Remove Last Scheme")) { FacebookSettings.AppLinkSchemes[i].Schemes.Pop(); } } EditorGUILayout.EndHorizontal(); } } }
private void AndroidUtilGUI() { showAndroidUtils = EditorGUILayout.Foldout(showAndroidUtils, "Android Build Facebook Settings"); if (showAndroidUtils) { if (!FacebookAndroidUtil.IsSetupProperly()) { var msg = "Your Android setup is not right. Check the documentation."; switch (FacebookAndroidUtil.SetupError) { case FacebookAndroidUtil.ERROR_NO_SDK: msg = "You don't have the Android SDK setup! Go to " + (Application.platform == RuntimePlatform.OSXEditor ? "Unity" : "Edit") + "->Preferences... and set your Android SDK Location under External Tools"; break; case FacebookAndroidUtil.ERROR_NO_KEYSTORE: msg = "Your android debug keystore file is missing! You can create new one by creating and building empty Android project in Ecplise."; break; case FacebookAndroidUtil.ERROR_NO_KEYTOOL: msg = "Keytool not found. Make sure that Java is installed, and that Java tools are in your path."; break; case FacebookAndroidUtil.ERROR_NO_OPENSSL: msg = "OpenSSL not found. Make sure that OpenSSL is installed, and that it is in your path."; break; case FacebookAndroidUtil.ERROR_KEYTOOL_ERROR: msg = "Unkown error while getting Debug Android Key Hash."; break; } EditorGUILayout.HelpBox(msg, MessageType.Warning); } EditorGUILayout.HelpBox("Copy and Paste these into your \"Native Android App\" Settings on developers.facebook.com/apps", MessageType.None); SelectableLabelField(packageNameLabel, PlayerSettings.bundleIdentifier); SelectableLabelField(classNameLabel, ManifestMod.DeepLinkingActivityName); SelectableLabelField(debugAndroidKeyLabel, FacebookAndroidUtil.DebugKeyHash); if (GUILayout.Button("Regenerate Android Manifest")) { ManifestMod.GenerateManifest(); } } EditorGUILayout.Space(); }
public static void OnPostProcessBuild(BuildTarget target, string path) { // If integrating with facebook on any platform, throw a warning if the app id is invalid if (!FacebookSettings.IsValidAppId) { Debug.LogWarning("You didn't specify a Facebook app ID. Please add one using the Facebook menu in the main Unity editor."); } // Unity renamed build target from iPhone to iOS in Unity 5, this keeps both versions happy if (target.ToString() == "iOS" || target.ToString() == "iPhone") { UpdatePlist(path); FixupFiles.FixSimulator(path); FixupFiles.AddVersionDefine(path); FixupFiles.FixColdStart(path); FixupFiles.AddBuildFlag(path); } if (target == BuildTarget.Android) { // The default Bundle Identifier for Unity does magical things that causes bad stuff to happen var defaultIdentifier = "com.Company.ProductName"; if (Utility.GetApplicationIdentifier() == defaultIdentifier) { Debug.LogError("The default Unity Bundle Identifier (com.Company.ProductName) will not work correctly."); } if (!FacebookAndroidUtil.SetupProperly) { Debug.LogError("Your Android setup is not correct. See Settings in Facebook menu."); } if (!ManifestMod.CheckManifest()) { // If something is wrong with the Android Manifest, try to regenerate it to fix it for the next build. ManifestMod.GenerateManifest(); } } }
private void AppIdGUI() { EditorGUILayout.LabelField("Add the Facebook App Id(s) associated with this game"); if (FacebookSettings.AppIds.Count == 0 || FacebookSettings.AppId == "0") { EditorGUILayout.HelpBox("Invalid App Id", MessageType.Error); } for (int i = 0; i < FacebookSettings.AppIds.Count; ++i) { EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(string.Format("App #{0}", i + 1)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(this.appNameLabel); FacebookSettings.AppLabels[i] = EditorGUILayout.TextField(FacebookSettings.AppLabels[i]); EditorGUILayout.EndHorizontal(); GUI.changed = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(this.appIdLabel); FacebookSettings.AppIds[i] = EditorGUILayout.TextField(FacebookSettings.AppIds[i]); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(this.clientTokenLabel); FacebookSettings.ClientTokens[i] = EditorGUILayout.TextField(FacebookSettings.ClientTokens[i]); EditorGUILayout.EndHorizontal(); if (GUI.changed) { this.SettingsChanged(); ManifestMod.GenerateManifest(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Another App Id")) { FacebookSettings.AppLabels.Add("New App"); FacebookSettings.AppIds.Add("0"); FacebookSettings.ClientTokens.Add(string.Empty); FacebookSettings.AppLinkSchemes.Add(new FacebookSettings.UrlSchemes()); this.SettingsChanged(); } if (FacebookSettings.AppLabels.Count > 1) { if (GUILayout.Button("Remove Last App Id")) { FacebookSettings.AppLabels.Pop(); FacebookSettings.AppIds.Pop(); FacebookSettings.ClientTokens.Pop(); FacebookSettings.AppLinkSchemes.Pop(); this.SettingsChanged(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (FacebookSettings.AppIds.Count > 1) { EditorGUILayout.HelpBox("2) Select Facebook App Id to be compiled with this game", MessageType.None); GUI.changed = false; FacebookSettings.SelectedAppIndex = EditorGUILayout.Popup( "Selected App Id", FacebookSettings.SelectedAppIndex, FacebookSettings.AppIds.ToArray()); if (GUI.changed) { ManifestMod.GenerateManifest(); } EditorGUILayout.Space(); } else { FacebookSettings.SelectedAppIndex = 0; } }
private void AppIdGUI() { EditorGUILayout.HelpBox("1) Add the Facebook App Id(s) associated with this game", MessageType.None); if (instance.AppIds.Length == 0 || instance.AppIds[instance.SelectedAppIndex] == "0") { EditorGUILayout.HelpBox("Invalid App Id", MessageType.Error); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(appNameLabel); EditorGUILayout.LabelField(appIdLabel); EditorGUILayout.EndHorizontal(); for (int i = 0; i < instance.AppIds.Length; ++i) { EditorGUILayout.BeginHorizontal(); instance.SetAppLabel(i, EditorGUILayout.TextField(instance.AppLabels[i])); GUI.changed = false; instance.SetAppId(i, EditorGUILayout.TextField(instance.AppIds[i])); if (GUI.changed) { ManifestMod.GenerateManifest(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Another App Id")) { var appLabels = new List <string>(instance.AppLabels); appLabels.Add("New App"); instance.AppLabels = appLabels.ToArray(); var appIds = new List <string>(instance.AppIds); appIds.Add("0"); instance.AppIds = appIds.ToArray(); } if (instance.AppLabels.Length > 1) { if (GUILayout.Button("Remove Last App Id")) { var appLabels = new List <string>(instance.AppLabels); appLabels.RemoveAt(appLabels.Count - 1); instance.AppLabels = appLabels.ToArray(); var appIds = new List <string>(instance.AppIds); appIds.RemoveAt(appIds.Count - 1); instance.AppIds = appIds.ToArray(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (instance.AppIds.Length > 1) { EditorGUILayout.HelpBox("2) Select Facebook App Id to be compiled with this game", MessageType.None); GUI.changed = false; instance.SetAppIndex(EditorGUILayout.Popup("Selected App Id", instance.SelectedAppIndex, instance.AppLabels)); if (GUI.changed) { ManifestMod.GenerateManifest(); } EditorGUILayout.Space(); } else { instance.SetAppIndex(0); } }