static void SignAssetBundles()
        {
            AssetBundleBuildConfig config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);

            if (config == null)
            {
                return;
            }

            ABBuilder builder = new AssetBundleBuilder(new AssetBundlePathResolver(), true);

            builder.SetDataWriter(config.depInfoFileFormat == AssetBundleBuildConfig.Format.Text ? new AssetBundleDataWriter() : new AssetBundleDataBinaryWriter());

            builder.Begin();

            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilter f = config.filters[i];
                if (f.valid)
                {
                    builder.AddRootTargets(new DirectoryInfo(f.path), new string[] { f.filter });
                }
            }

            builder.Export();
            builder.End();
        }
Exemple #2
0
        static void Buildupdate()
        {
            GameObject wwwMange = new GameObject();

            wwwMange.AddComponent <WWWManager>();

            AssetBundleBuildConfig config = AssetBundleBuildPanel.LoadConfig();

            AssetBundleBuilder.Build(config);

            VersionConfig newCfg    = getNewVersion();
            string        url       = getServerUrl().Combine(GameUpdater.CurrentVersionPath);
            string        cachePath = GameUpdater.CacheVersionPath;

            Debug.LogError("加载服务端version信息……");
            GameUpdater.Instance.DeleteCacheVersion();
            WWWManager.Instance.DownloadWWW(url, cachePath, (suc) =>
            {
                VersionConfig serverCfg = VersionUtil.ReadConfig(cachePath);
                List <string> files     = GameUpdater.Instance.GetFileListNeedDownloaded(serverCfg, newCfg);
                Debug.LogError("需要更新的ab包个数:" + files.Count);
                FileUtil.DeleteFileOrDirectory(cachePath);
                copyToUpdate(files);
                GameObject.DestroyImmediate(wwwMange);
                Debug.LogError("外网更新打包结束!");
            });
        }
 private void Build()
 {
     Save();
     AssetBundleBuilder.Build(config);
 }
        void OnGUI()
        {
            bool hasNotValid = false;
            bool hasValid    = false;

            if (config == null)
            {
                config = LoadConfig();
                if (config == null)
                {
                    config = new AssetBundleBuildConfig();
                }
            }

            UpdateStyles();

            GUILayout.BeginHorizontal(Styles.toolbar);
            {
                for (int i = 0; i < config.filters.Count; ++i)
                {
                    if (!config.filters[i].valid)
                    {
                        hasNotValid = true;
                    }
                    else
                    {
                        hasValid = true;
                    }
                }

                if (GUILayout.Button(hasNotValid ? "SelectAll" : "UnselectAll", Styles.toolbarButton))
                {
                    for (int i = 0; i < config.filters.Count; ++i)
                    {
                        config.filters[i].valid = hasNotValid;
                    }
                }

                if (GUILayout.Button("Add", Styles.toolbarButton))
                {
                    config.filters.Add(new AssetBundleFilterMain());
                }

                if (GUILayout.Button("Gen", Styles.toolbarButton))
                {
                    AssetBundleBuilder.Build(config, true);
                }

                if (GUILayout.Button("Clear", Styles.toolbarButton))
                {
                    EditorApplication.delayCall += () =>
                    {
                        PathUtil.DeleteFileOrFolder(Application.streamingAssetsPath);
                        AssetDatabase.Refresh();
                        TTLoger.Log("清理完成!");
                    };
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            UnityEngine.Event e = UnityEngine.Event.current;
            if (e.type == EventType.scrollWheel)
            {
                scrollPos = new Vector2(0f, scrollPos.y + (-10) * e.delta.y);
            }
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);

            GUILayout.BeginVertical();
            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilterMain filter = config.filters[i];
                i -= DrawMainFilter(filter);
            }

            if (!hasValid)
            {
                GUI.enabled = false;
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Build"))
            {
                EditorApplication.delayCall += Build;
            }
            if (!hasValid)
            {
                GUI.enabled = true;
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            //set dirty
            if (GUI.changed)
            {
                Save();
            }

            UpdateEvent();
            Repaint();
        }