public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        string pathToPlayerData         = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + "_Data");
        string pathToPlayerDataMiddleVR = Path.Combine(pathToPlayerData, "MiddleVR");

        // Copy web assets
        string webAssetsPathSource = Path.Combine(Path.Combine(Application.dataPath, "MiddleVR"), "WebAssets");

        if (Directory.Exists(webAssetsPathSource))
        {
            // The player executable file and the data folder share the same base name
            string webAssetsPathDestination = Path.Combine(pathToPlayerDataMiddleVR, "WebAssets");
            FileSystemTools.DirectoryCopy(webAssetsPathSource, webAssetsPathDestination, true, true);
        }

        // Copy web assets in hidden directory
        string dotWebAssetsPathSource = Path.Combine(Path.Combine(Application.dataPath, "MiddleVR"), ".WebAssets");

        if (Directory.Exists(dotWebAssetsPathSource))
        {
            // The player executable file and the data folder share the same base name
            string dotWebAssetsPathDestination = Path.Combine(pathToPlayerDataMiddleVR, ".WebAssets");
            FileSystemTools.DirectoryCopy(dotWebAssetsPathSource, dotWebAssetsPathDestination, true, true);
        }

        // Sign Application
        MVRTools.SignApplication(pathToBuiltProject);
    }
Пример #2
0
    private static void CopyFolderIfExists(string iFolderName, string iSrcBasePath, string iDstBasePath)
    {
        string sourcePath = Path.Combine(iSrcBasePath, iFolderName);

        if (Directory.Exists(sourcePath))
        {
            // The player executable file and the data folder share the same base name
            string destinationPath = Path.Combine(iDstBasePath, iFolderName);
            FileSystemTools.DirectoryCopy(sourcePath, destinationPath, true, true);
        }
    }
Пример #3
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        string renderingPlugin32Path = pathToBuiltProject.Replace(".exe", "_Data/Plugins/MiddleVR_UnityRendering.dll");
        string renderingPlugin64Path = pathToBuiltProject.Replace(".exe", "_Data/Plugins/MiddleVR_UnityRendering_x64.dll");

        switch (target)
        {
        case BuildTarget.StandaloneWindows:
        {
            Debug.Log("[ ] 32-bit build : delete " + renderingPlugin64Path);

            // Delete x64 version
            if (System.IO.File.Exists(renderingPlugin64Path))
            {
                System.IO.File.Delete(renderingPlugin64Path);
            }

            break;
        }

        case BuildTarget.StandaloneWindows64:
        {
            Debug.Log("[ ] 64-bit build : delete " + renderingPlugin32Path + " and rename " + renderingPlugin64Path);

            // Delete 32b version...
            if (System.IO.File.Exists(renderingPlugin32Path))
            {
                System.IO.File.Delete(renderingPlugin32Path);
            }

            // ...and rename x64 version
            if (System.IO.File.Exists(renderingPlugin64Path))
            {
                System.IO.File.Move(renderingPlugin64Path, renderingPlugin32Path);
            }

            break;
        }
        }

        // Copy web assets for HTML5 default GUI
        string webAssetsPathSource      = Application.dataPath + System.IO.Path.DirectorySeparatorChar + "/MiddleVR/.WebAssets";
        string webAssetsPathDestination = pathToBuiltProject.Replace(".exe", "_Data/MiddleVR/.WebAssets");

        FileSystemTools.DirectoryCopy(webAssetsPathSource, webAssetsPathDestination, true, true);

        // Sign Application
        MVRTools.SignApplication(pathToBuiltProject);
    }
Пример #4
0
    public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        // If this is not a MiddleVR package import, skip
        bool importingMvrDll = false;

        foreach (string s in importedAssets)
        {
            // MiddleVR_Unity3D.dll should be imported only at package import
            if (s.Contains("MiddleVR_Unity3D.dll"))
            {
                importingMvrDll = true;
                break;
            }
        }

        if (!importingMvrDll)
        {
            return;
        }

        Debug.Log("[ ] Package import post process: import GUI web assets from Program Files...");

        // Copy web assets from MiddleVR installation folders

        // Find MiddleVR installation folder from Path environment variable
        string mvrDllPath = FileSystemTools.FindFileInPath("MiddleVR.dll");

        if (mvrDllPath == "")
        {
            EditorUtility.DisplayDialog("MiddleVR package import error", "MiddleVR installation folder was not found\nDid you install MiddleVR on this computer and did you restart after MiddleVR installation?\nYou should restart and re-import the MiddleVR Unity package.", "Ok");
            return;
        }

        // Replace the dll path by the menu path
        char separator            = System.IO.Path.DirectorySeparatorChar;
        int  lastPathSeparatorPos = mvrDllPath.LastIndexOf(separator);

        mvrDllPath           = mvrDllPath.Remove(lastPathSeparatorPos);
        lastPathSeparatorPos = mvrDllPath.LastIndexOf(separator);
        mvrDllPath           = mvrDllPath.Remove(lastPathSeparatorPos);

        string webAssetsPathSource      = mvrDllPath + separator + "data" + separator + "GUI" + separator + "Menu";
        string webAssetsPathDestination = Application.dataPath + "/MiddleVR/.WebAssets/VRMenu";

        Debug.Log("[ ] Trying to copy folder '" + webAssetsPathSource + "' to " + webAssetsPathDestination + "'...");

        // If destination already exists, update it
        if (System.IO.Directory.Exists(webAssetsPathDestination))
        {
            Debug.Log("[ ] Destination folder '" + webAssetsPathDestination + "' already exists, updating it...");
        }

        if (System.IO.Directory.Exists(webAssetsPathSource))
        {
            FileSystemTools.DirectoryCopy(webAssetsPathSource, webAssetsPathDestination, true, true);
        }
        else
        {
            EditorUtility.DisplayDialog("MiddleVR package import error", "Web assets folder was not found:\n'" + webAssetsPathSource + "'\nYou should manually copy the content of the folder '/data/GUI/Menu' from your MiddleVR installation location to:\n'" + webAssetsPathDestination + "'", "Ok");
        }

        if (!System.IO.File.Exists(Application.dataPath + "/MiddleVR_Source_Project.txt"))
        {
            // Clean old deprecated files from previous MiddleVR versions
            string[] filesToDelete = { "/Editor/VRCustomEditor.cs",
                                       "/Resources/OVRLensCorrectionMat.mat",
                                       "/MiddleVR/Scripts/Internal/VRCameraCB.cs",
                                       "/MiddleVR/Assets/Materials/WandRayMaterial.mat" };

            foreach (string fileToDelete in filesToDelete)
            {
                string filePath = Application.dataPath + fileToDelete;
                if (System.IO.File.Exists(filePath))
                {
                    Debug.Log("[ ] Package import post process: clean deprecated MiddleVR files. Deleting file '" + filePath + "'.");
                    System.IO.File.Delete(filePath);
                }
            }
        }

        Debug.Log("[ ] Package import post process: End.");
    }