public virtual void CopyJavaFilesAndReplacePackageName(string RootSourceDir, string RootDestDir) { List <string> JavaFilesToCopy = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(RootSourceDir, true, false, true, true, true); foreach (string CurrentFile in JavaFilesToCopy) { if (CurrentFile.EndsWith(".java") || CurrentFile.EndsWith(".aidl")) { string RelativeFilePath = CurrentFile.Substring(RootSourceDir.Length + 1); string NewDestinationPath = Path.Combine(RootDestDir, RelativeFilePath); if (!Directory.Exists(Path.GetDirectoryName(NewDestinationPath))) { Directory.CreateDirectory(Path.GetDirectoryName(NewDestinationPath)); } if (!File.Exists(NewDestinationPath)) { IgorRuntimeUtils.CopyFile(CurrentFile, NewDestinationPath); IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "com.facebook.android.R", PlayerSettings.bundleIdentifier + ".R"); IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "import com.facebook.android.*;", "import com.facebook.android.*;\nimport " + PlayerSettings.bundleIdentifier + ".R;"); IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "com.facebook.android.BuildConfig", PlayerSettings.bundleIdentifier + ".BuildConfig"); IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "import com.mikamikem.AndroidUnity.R;", "import " + PlayerSettings.bundleIdentifier + ".R;"); } } } }
public virtual bool UpdateXCodeProj() { string FacebookID = GetParamOrConfigString(FacebookIDFlag, "Your Facebook ID hasn't been set! Facebook functionality will probably not work correctly."); string FacebookDisplayName = GetParamOrConfigString(FacebookDisplayNameFlag, "Your Facebook Display Name hasn't been set! Facebook functionality will probably not work correctly."); List <string> BuildProducts = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!")) { string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj"); string FacebookIntegrationGUID = IgorXCodeProjUtils.AddNewFileReference(this, ProjectPath, "FacebookIntegration.h", TreeEnum.GROUP); IgorXCodeProjUtils.SortGUIDIntoGroup(this, ProjectPath, FacebookIntegrationGUID, "Libraries"); IgorXCodeProjUtils.AddFramework(this, ProjectPath, "FacebookSDK.framework", TreeEnum.GROUP, "Libraries/FacebookSDK.framework", -1, "wrapper.framework", "FacebookSDK.framework"); IgorXCodeProjUtils.AddFrameworkSearchPath(this, ProjectPath, "$(SRCROOT)/Libraries"); string PlistPath = Path.Combine(BuildProducts[0], "Info.plist"); IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookAppID", FacebookID); IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookDisplayName", FacebookDisplayName); IgorPlistUtils.AddBundleURLType(this, PlistPath, "fb" + FacebookID); IgorZip.UnzipArchiveCrossPlatform(this, Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("iOS", Path.Combine("FacebookSDK", "FacebookSDK.framework.zip"))))), Path.Combine(BuildProducts[0], "Libraries")); IgoriOSSourceUtils.AddHeaderToAppControllerSource(this, BuildProducts[0], "../Libraries/FacebookIntegration.h"); IgoriOSSourceUtils.AddFunctionToAppControllerSource(this, BuildProducts[0], "/* Pre iOS 4.2 support */\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n\treturn [FBSession.activeSession handleOpenURL:url];\n}\n"); IgorUtils.ReplaceStringsInFile(this, Path.Combine(BuildProducts[0], Path.Combine("Classes", "UnityAppController.mm")), "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn YES;", "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return [FBSession.activeSession handleOpenURL:url];"); IgoriOSSourceUtils.AddSourceToApplicationDidBecomeActive(this, BuildProducts[0], "[FBSession.activeSession handleDidBecomeActive];"); } return(true); }
public static void AddSourceToApplicationDidBecomeActive(IIgorModule ModuleInst, string PathToProject, string AdditionalSource) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "printf_console(\"-> applicationDidBecomeActive()\\n\");", AdditionalSource + "\nprintf_console(\"-> applicationDidBecomeActive()\\n\");"); }
public static void AddFunctionToAppControllerSource(IIgorModule ModuleInst, string PathToProject, string FunctionSource) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "@implementation UnityAppController", "@implementation UnityAppController\n" + FunctionSource); }
public static void AddHeaderToAppControllerSource(IIgorModule ModuleInst, string PathToProject, string HeaderFile) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "@implementation UnityAppController", "#import \"" + HeaderFile + "\"\n@implementation UnityAppController"); }