Ejemplo n.º 1
0
        public static void ValidateBundleDependencies(string manifestPath, string bundlePath)
        {
            var manifestText = File.ReadAllText(manifestPath);
            var manifest     = JsonUtility.FromJson <BundlerManifest>(manifestText);

            BundlerGenerator.ValidateBundleDependencies(manifest, bundlePath);
        }
Ejemplo n.º 2
0
        private static void GenerateAssetBundles(BuildTarget platform)
        {
            var manifestFile =
                PathUtility.Combine(BundlerBuildSettings.kBundlePath, BundlerBuildSettings.kManifestFileName);
            var manifestFileFullPath = PathUtility.Combine(Application.streamingAssetsPath, manifestFile);

            if (!File.Exists(manifestFileFullPath))
            {
                EditorUtility.DisplayDialog("Error", "Please generate bundler manifest first.", "OK");
                return;
            }

            var manifestText = File.ReadAllText(manifestFileFullPath);
            var manifest     = JsonUtility.FromJson <BundlerManifest>(manifestText);
            var outputPath   = PathUtility.Combine(Application.streamingAssetsPath, BundlerBuildSettings.kBundlePath);

            BundlerGenerator.GenerateAssetBundles(manifest, platform, outputPath);
        }
Ejemplo n.º 3
0
        private static void RegenerateAssetBundle(string path, BuildTarget platform)
        {
            var bundleOutputFullPath =
                PathUtility.Combine(Application.streamingAssetsPath, BundlerBuildSettings.kBundlePath);
            var bundleOutputRelativePath = PathUtility.AbsolutePathToRelativeProjectPath(bundleOutputFullPath);
            var manifestFilePath         = PathUtility.Combine(bundleOutputFullPath, BundlerBuildSettings.kManifestFileName);

            var bundleName = path.Substring(bundleOutputRelativePath.Length + 1);
            var jsonText   = File.ReadAllText(manifestFilePath);
            var manifest   = JsonUtility.FromJson <BundlerManifest>(jsonText);

            if (!manifest.bundles.ContainsKey(bundleName))
            {
                Debug.LogErrorFormat("Cannot found asset bundle in manifest: {0}", bundleName);
                return;
            }

            BundlerGenerator.RegenerateAssetBundle(manifest, bundleName, platform, bundleOutputRelativePath);
        }
Ejemplo n.º 4
0
        public static void GenerateManifest()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var buildRuleFile         = PathUtility.RelativeDataPathToAbsolutePath(BundlerBuildSettings.kBuildRuleFilePath);
            var relativeBuildRuleFile = PathUtility.AbsolutePathToRelativeProjectPath(buildRuleFile);
            var buildRuleAsset        = AssetDatabase.LoadAssetAtPath <TextAsset>(relativeBuildRuleFile);
            var buildRule             = JsonUtility.FromJson <BundlerBuildRule>(buildRuleAsset.text);

            var outputPath =
                PathUtility.Combine(BundlerBuildSettings.kBundlePath, BundlerBuildSettings.kManifestFileName);
            var fullPath = PathUtility.Combine(Application.streamingAssetsPath, outputPath);

            BundlerGenerator.GenerateManifestToFile(buildRule, fullPath);

            stopWatch.Stop();
            Debug.Log(string.Format("Generate manifest finished, cost: {0}s", stopWatch.Elapsed.TotalSeconds));
        }
Ejemplo n.º 5
0
        public static void StripUnmanagedFiles()
        {
            var buildRuleFile         = PathUtility.RelativeDataPathToAbsolutePath(BundlerBuildSettings.kBuildRuleFilePath);
            var relativeBuildRuleFile = PathUtility.AbsolutePathToRelativeProjectPath(buildRuleFile);
            var buildRuleAsset        = AssetDatabase.LoadAssetAtPath <TextAsset>(relativeBuildRuleFile);
            var buildRule             = JsonUtility.FromJson <BundlerBuildRule>(buildRuleAsset.text);

            var manifestFile =
                PathUtility.Combine(BundlerBuildSettings.kBundlePath, BundlerBuildSettings.kManifestFileName);
            var manifestFileFullPath = PathUtility.Combine(Application.streamingAssetsPath, manifestFile);

            if (!File.Exists(manifestFileFullPath))
            {
                EditorUtility.DisplayDialog("Error", "Please generate bundler manifest first.", "OK");
                return;
            }

            var manifestText = File.ReadAllText(manifestFileFullPath);
            var manifest     = JsonUtility.FromJson <BundlerManifest>(manifestText);

            BundlerGenerator.StripUnmanagedFiles(buildRule, manifest);
            manifestText = JsonUtility.ToJson(manifest);
            File.WriteAllText(manifestFileFullPath, manifestText);
        }