コード例 #1
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
#if UNITY_5
            if (target != BuildTarget.iOS)
            {
                return;
            }
#else
            if (target != BuildTarget.iPhone)
            {
                return;
            }
#endif

            #if NO_GPGS
            Debug.Log("Removing AppController code since NO_GPGS is defined");
            // remove plugin code from generated project
            string pluginDir = pathToBuiltProject + "/Libraries/Plugins/iOS";
            if (System.IO.Directory.Exists(pluginDir))
            {
                GPGSUtil.WriteFile(pluginDir + "/GPGSAppController.mm", "// Empty since NO_GPGS is defined\n");
                return;
            }
            #else
            if (GetBundleId() == null)
            {
                UnityEngine.Debug.LogError("The iOS bundle ID has not been set up through the " +
                                           "'iOS Setup' submenu of 'Google Play Games' - the generated xcode project will " +
                                           "not work properly.");
                return;
            }

            //Copy the podfile into the project.
            string podfile     = "Assets/GooglePlayGames/Editor/Podfile.txt";
            string destpodfile = pathToBuiltProject + "/Podfile";
            if (!System.IO.File.Exists(destpodfile))
            {
                FileUtil.CopyFileOrDirectory(podfile, destpodfile);
            }

            GPGSInstructionWindow w = EditorWindow.GetWindow <GPGSInstructionWindow>(
                true,
                "Building for IOS",
                true);
            w.UsingCocoaPod = CocoaPodHelper.Update(pathToBuiltProject);

            UnityEngine.Debug.Log("Adding URL Types for authentication using PlistBuddy.");

            UpdateGeneratedInfoPlistFile(pathToBuiltProject + "/Info.plist");
            UpdateGeneratedPbxproj(pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj");
        #endif
        }
コード例 #2
0
ファイル: GPGSPostBuild.cs プロジェクト: xon235/TeleportUp
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
#if UNITY_5
            if (target != BuildTarget.iOS)
            {
                if (!GPGSProjectSettings.Instance.GetBool(GPGSUtil.ANDROIDSETUPDONEKEY, false))
                {
                    EditorUtility.DisplayDialog("Google Play Games not configured!",
                                                "Warning!!  Google Play Games was not configured, Game Services will not work correctly.",
                                                "OK");
                }
                return;
            }
#else
            if (target != BuildTarget.iPhone)
            {
                return;
            }
#endif

            #if NO_GPGS
            string[] filesToRemove =
            {
                "Libraries/Plugins/iOS/GPGSAppController.mm",
                "Libraries/GPGSAppController.mm",
                "Libraries/Plugins/iOS/GPGSAppController.h",
                "Libraries/GPGSAppController.h",
                "Libraries/Plugins/iOS/CustomWebViewApplication.h",
                "Libraries/CustomWebViewApplication.h",
                "Libraries/Plugins/iOS/CustomWebViewApplication.mm",
                "Libraries/CustomWebViewApplication.mm"
            };

            string     pbxprojPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
            PBXProject proj        = new PBXProject();
            proj.ReadFromString(File.ReadAllText(pbxprojPath));

            foreach (string name in filesToRemove)
            {
                string fileGuid = proj.FindFileGuidByProjectPath(name);
                if (fileGuid != null)
                {
                    Debug.Log("Removing " + name + " from xcode project");
                    proj.RemoveFile(fileGuid);
                }
            }

            File.WriteAllText(pbxprojPath, proj.WriteToString());
            #else
            if (!GPGSProjectSettings.Instance.GetBool(GPGSUtil.IOSSETUPDONEKEY, false))
            {
                EditorUtility.DisplayDialog("Google Play Games not configured!",
                                            "Warning!!  Google Play Games was not configured, Game Services will not work correctly.",
                                            "OK");
            }

            if (GetBundleId() == null)
            {
                UnityEngine.Debug.LogError("The iOS bundle ID has not been set up through the " +
                                           "'iOS Setup' submenu of 'Google Play Games' - the generated xcode project will " +
                                           "not work properly.");
                return;
            }

            //Copy the podfile into the project.
            string podfile     = "Assets/GooglePlayGames/Editor/Podfile.txt";
            string destpodfile = pathToBuiltProject + "/Podfile";
            if (!System.IO.File.Exists(destpodfile))
            {
                FileUtil.CopyFileOrDirectory(podfile, destpodfile);
            }

            GPGSInstructionWindow w = EditorWindow.GetWindow <GPGSInstructionWindow>(
                true,
                "Building for IOS",
                true);
            w.minSize       = new Vector2(400, 300);
            w.UsingCocoaPod = CocoaPodHelper.Update(pathToBuiltProject);

            UnityEngine.Debug.Log("Adding URL Types for authentication using PlistBuddy.");

            UpdateGeneratedInfoPlistFile(pathToBuiltProject + "/Info.plist");
            UpdateGeneratedPbxproj(pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj");
        #endif
        }