基于Tab表格的纯文本简单资源差异管理器
Inheritance: IDisposable
Beispiel #1
0
        public static void BuildAllAssetBundles()
        {
            if (EditorApplication.isPlaying)
            {
                Log.Error("Cannot build in playing mode! Please stop!");
                return;
            }
            AssetVersionControl ac = new AssetVersionControl(true);

            MakeAssetBundleNames();
            ac.Dispose();
            var outputPath = GetExportPath(EditorUserBuildSettings.activeBuildTarget);

            Log.Info("Asset bundle start build to: {0}", outputPath);
            BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);
        }
Beispiel #2
0
        public static void MakeAssetBundleNames()
        {
            var dir = ResourcesBuildDir;

            // Check marked asset bundle whether real
            foreach (var assetGuid in AssetDatabase.FindAssets(""))
            {
                var assetPath     = AssetDatabase.GUIDToAssetPath(assetGuid);
                var assetImporter = AssetImporter.GetAtPath(assetPath);
                var bundleName    = assetImporter.assetBundleName;
                if (string.IsNullOrEmpty(bundleName))
                {
                    continue;
                }
                if (!assetPath.StartsWith(dir))
                {
                    assetImporter.assetBundleName = null;
                }
            }

            // set BundleResources's all bundle name
            foreach (var filepath in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories))
            {
                if (filepath.EndsWith(".meta"))
                {
                    continue;
                }

                var importer = AssetImporter.GetAtPath(filepath);
                if (importer == null)
                {
                    Log.Error("Not found: {0}", filepath);
                    continue;
                }
                var bundleName = filepath.Substring(dir.Length, filepath.Length - dir.Length);
                importer.assetBundleName = bundleName + AppEngine.GetConfig(KEngineDefaultConfigs.AssetBundleExt);

                bool needBuild = AssetVersionControl.TryCheckNeedBuildWithMeta(filepath);
                if (needBuild)
                {
                    AssetVersionControl.TryMarkBuildVersion(filepath);
                    Debug.Log("version: " + filepath);
                }
            }

            Log.Info("Make all asset name successs!");
        }
        public void Dispose()
        {
            WriteVersion();
            if (BuildedList.Count > 0)
            {
                //ProductMd5_CurPlatform();
                Log.Info("一共打包了{0}個資源:\n{1}", BuildedList.Count, string.Join("\n", BuildedList.ToArray()));
            }
            else
                Log.Info("没有任何需要打包的资源!");

            //KDependencyBuild.SaveBuildAction();

            Current = null;
#if UNITY_4
            BuildTools.AfterBuildAssetBundleEvent -= OnAfterBuildAssetBundleEvent;
#endif
            //KDependencyBuild.Clear();
        }
        /// <summary>
        /// 资源打包周期版本管理
        /// </summary>
        /// <param name="rebuild">如果是rebuild,将无视之前的差异打包信息</param>
        public AssetVersionControl(bool rebuild = false)
        {
            if (Current != null)
            {
                Log.Error("New a KAssetVersionControl, but already has annother instance using! Be careful!");
            }

            Current = this;

            _isRebuild = rebuild;

            Log.Warning("================== KAssetVersionControl Begin ======================");

            SetupHistory();

            //KDependencyBuild.Clear();
#if !UNITY_5
            BuildTools.AfterBuildAssetBundleEvent += OnAfterBuildAssetBundleEvent;
#endif
        }
        /// <summary>
        /// 资源打包周期版本管理
        /// </summary>
        /// <param name="rebuild">如果是rebuild,将无视之前的差异打包信息</param>
        public AssetVersionControl(bool rebuild = false)
        {
            if (Current != null)
            {
                Log.Error("New a KAssetVersionControl, but already has annother instance using! Be careful!");
            }

            Current = this;

            _isRebuild = rebuild;

            Log.Warning("================== KAssetVersionControl Begin ======================");

            SetupHistory();

            //KDependencyBuild.Clear();
            #if !UNITY_5
            BuildTools.AfterBuildAssetBundleEvent += OnAfterBuildAssetBundleEvent;
            #endif
        }
        public void Dispose()
        {
            WriteVersion();
            if (BuildedList.Count > 0)
            {
                //ProductMd5_CurPlatform();
                Log.Info("一共打包了{0}個資源:\n{1}", BuildedList.Count, string.Join("\n", BuildedList.ToArray()));
            }
            else
                Log.Info("没有任何需要打包的资源!");

            //KDependencyBuild.SaveBuildAction();

            Current = null;
            #if !UNITY_5
            BuildTools.AfterBuildAssetBundleEvent -= OnAfterBuildAssetBundleEvent;
            #endif
            //KDependencyBuild.Clear();
        }