Exemple #1
0
    public static void BuildAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = Path.Combine(IPathTools.kAssetBundlesOutputPath, GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget));


        //  outputPath=  Path.Combine(outputPath,PrecisionPlatform);
        if (!Directory.Exists(outputPath))
        {
            Debug.Log(outputPath);
            Directory.CreateDirectory(outputPath);
        }


        Debug.Log("outputPath ===" + outputPath);


        Debug.Log("active  ===" + EditorUserBuildSettings.activeBuildTarget);


        BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);


        string outputFolder = GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget);

        // Setup the source folder for assetbundles.
        var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, IPathTools.kAssetBundlesOutputPath), outputFolder);

        if (!System.IO.Directory.Exists(source))
        {
            Debug.Log("No assetBundle output folder, try to build the assetBundles first.");
        }


        string distPath = Path.Combine(Application.streamingAssetsPath, IPathTools.kAssetBundlesOutputPath);

        distPath = Path.Combine(distPath, outputFolder);


        //distPath = IPathTools.FixedPath(distPath);

        IFileTools.CopyFolder(source, distPath);

        AssetDatabase.Refresh();
    }