public KeyStoreInfo()
 {
     // Construct the default Android debug keystore info
     // http://developer.android.com/tools/publishing/app-signing.html
     KeyStoreFile = Path.Combine(AndroidPostProcessor.GetUserDir(), ".android/debug.keystore");
     StorePass    = "******";
     KeyPass      = "******";
     Alias        = "androiddebugkey";
 }
Example #2
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (!IsTargetPlatformSupported(target))
        {
            if (Directory.Exists(Path.Combine(pathToBuiltProject, "StreamingAssets/CoherentUI_Host")))
            {
                Directory.Delete(Path.Combine(pathToBuiltProject, "StreamingAssets/CoherentUI_Host"), true);
            }

            Debug.Log("Coherent UI package installed in a project targeting unsupported platfrom (" + target + ")!");
            return;
        }

        var outDir = Path.GetDirectoryName(pathToBuiltProject);

        var projName = "";

        if (target == BuildTarget.iPhone)
        {
            var slashDelim = pathToBuiltProject.LastIndexOf('/');

            if (slashDelim != -1)
            {
                projName = pathToBuiltProject.Substring(slashDelim + 1);
            }
            else
            {
                Debug.Log("Ivalid path to build project passed!");
                return;
            }
        }
        else
        {
            projName = Path.GetFileNameWithoutExtension(pathToBuiltProject);
        }

        var resourcesFolder = PlayerPrefs.GetString("CoherentUIResources");

#if !COHERENT_UNITY_PRE_4_2
        if (target == BuildTarget.Android)
        {
            outDir   = pathToBuiltProject;
            projName = PlayerSettings.productName;
        }
#endif

        // check for per-project override
        if (string.IsNullOrEmpty(resourcesFolder))
        {
            FieldInfo projectUIResourcesStr = typeof(CoherentPostProcessor).GetField("ProjectUIResources", BindingFlags.Public | BindingFlags.Static);
            if (projectUIResourcesStr != null)
            {
                string projectResFolder = (string)projectUIResourcesStr.GetValue(null);
                Debug.Log(String.Format("[Coherent UI]: Found project resources folder: {0}", projectResFolder));
                resourcesFolder = projectResFolder;
            }
        }

        bool   buildingAndroidApk = false;
        string androidUnpackDir   = Path.Combine(Application.dataPath, "../Temp/CouiApkRepack");
        if (target == BuildTarget.Android && pathToBuiltProject.EndsWith(".apk"))
        {
            buildingAndroidApk = true;
        }

        if (buildingAndroidApk)
        {
            AndroidPostProcessor.FindAndCopySdkAaptAndZipalign();
            AndroidPostProcessor.UnpackAPK(pathToBuiltProject, androidUnpackDir);
        }

        // copy the UI resources
        if (!string.IsNullOrEmpty(resourcesFolder))
        {
            var    lastDelim  = resourcesFolder.LastIndexOf('/');
            string folderName = lastDelim != -1 ? resourcesFolder.Substring(lastDelim + 1) : resourcesFolder;

            StringBuilder outputDir         = new StringBuilder(outDir);
            string        uiResourcesFormat = null;
            switch (target)
            {
#if !COHERENT_UNITY_PRE_4_2
            case BuildTarget.StandaloneOSXIntel64:
            case BuildTarget.StandaloneOSXUniversal:
#endif
            case BuildTarget.StandaloneOSXIntel:
                uiResourcesFormat = "/{0}.app/Contents/{1}";
                break;

            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
#if !COHERENT_UNITY_PRE_4_2
            case BuildTarget.StandaloneLinux64:
#endif
                uiResourcesFormat = "/{0}_Data/{1}";
                break;

            case BuildTarget.iPhone:
                uiResourcesFormat = "/{0}/Data/{1}";
                break;

            case BuildTarget.Android:
                uiResourcesFormat = "/{0}/assets/{1}";                 // Format for exported Eclipse project
                break;

            default:
                new System.ApplicationException("Unsupported by Coherent UI build target");
                break;
            }

            var inDir = Path.Combine(Application.dataPath, resourcesFolder);

            if (!Directory.Exists(inDir))
            {
                resourcesFolder = Path.Combine("..", resourcesFolder);
                inDir           = Path.Combine(Application.dataPath, resourcesFolder);
            }

            if (buildingAndroidApk)
            {
                outputDir = new StringBuilder(Path.Combine(androidUnpackDir, "assets/" + folderName));
            }
            else
            {
                outputDir.AppendFormat(uiResourcesFormat, projName, folderName);
            }

            DirectoryCopy(inDir.ToString(), outputDir.ToString(), true);
        }

        switch (target)
        {
        case BuildTarget.StandaloneWindows:
        case BuildTarget.StandaloneWindows64:
            CleanUpForWindows(target, string.Format("{0}/{1}_Data/", outDir, projName));
            break;

#if !COHERENT_UNITY_PRE_4_2
        case BuildTarget.StandaloneLinux64:
            CleanUpForLinux(string.Format("{0}/{1}_Data/", outDir, projName));
            break;

        case BuildTarget.StandaloneOSXIntel64:
        case BuildTarget.StandaloneOSXUniversal:
#endif
        case BuildTarget.StandaloneOSXIntel:
            CleanUpForMacOSX(string.Format("{0}/{1}.app/", outDir, projName));
            break;

        case BuildTarget.iPhone:
            var outputFolder = string.Format("{0}/{1}/Data/Raw/", outDir, projName);
            IOSPostProcessor.PostProcess(pathToBuiltProject);
            CleanUpForMobile(outputFolder);
            break;

        case BuildTarget.Android:
            if (buildingAndroidApk)
            {
                AndroidPostProcessor.RepackAPK(pathToBuiltProject, androidUnpackDir);
            }
            else
            {
                bool apiLevel11OrGreater = (PlayerSettings.Android.minSdkVersion >= AndroidSdkVersions.AndroidApiLevel11);
                AndroidPostProcessor.ModifyManifestFile(string.Format("{0}/{1}/AndroidManifest.xml", outDir, projName), apiLevel11OrGreater);
                CleanUpForMobile(string.Format("{0}/{1}/assets/", outDir, projName));
                AndroidPostProcessor.CleanUpForAndroid(string.Format("{0}/{1}/Plugins", outDir, projName));

                AndroidPostProcessor.CopyMobileNetDll(
                    string.Format("{0}/{1}/assets/bin/Data/Managed",
                                  outDir, projName),
                    Path.Combine(Application.dataPath, "Plugins"));
            }
            break;

        default:
            new System.ApplicationException("Unsupported by Coherent UI build target");
            break;
        }
    }