Exemplo n.º 1
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("外网更新打包结束!");
            });
        }
Exemplo n.º 2
0
        public static void BuildAssetBundles()
        {
            AssetBundleBuildConfig config = AssetDatabase.LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
            ABBuilder builder             = new ABBuilder();

            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 && Directory.Exists(f.path))
                {
                    builder.AddRootTargets(new DirectoryInfo(f.path), new string[] { f.filter });
                }
            }
            for (int i = 0; i < config.files.Count; ++i)
            {
                AssetBundleFilter f = config.files[i];
                if (f.valid && File.Exists(f.path))
                {
                    builder.AddRootTargets(new FileInfo(f.path));
                }
            }
            builder.Analyze();
            builder.Export();
            builder.End();

            EditorUtility.DisplayDialog("AssetBundle Build Finish", "AssetBundle Build Finish!", "OK");
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
 void InitConfig()
 {
     _config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
     if (_config == null)
     {
         _config = CreateInstance <AssetBundleBuildConfig>();
     }
 }
Exemplo n.º 5
0
 public static void Save()
 {
     _config = AssetDatabase.LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
     if (_config == null)
     {
         AssetDatabase.CreateAsset(_config, savePath);
     }
     else
     {
         EditorUtility.SetDirty(_config);
     }
 }
Exemplo n.º 6
0
        public static void Build(AssetBundleBuildConfig config, bool isGenRes = false)
        {
            OnBuildStart(config, isGenRes);
            AssetBundleCollector collector = Collect(config);

            OnCollectFinish();
            if (!isGenRes)
            {
                collector.Build(Application.streamingAssetsPath);
            }
            OnBuildEnd(collector, isGenRes);
        }
Exemplo n.º 7
0
        public static AssetBundleCollector Collect(AssetBundleBuildConfig config)
        {
            AssetBundleCollector collector = new AssetBundleCollector();

            for (int i = 0; i < config.filters.Count; ++i)
            {
                AssetBundleFilterMain filter = config.filters[i];
                if (filter.valid)
                {
                    CollectMainFilter(filter, ref collector);
                }
            }
            return(collector);
        }
Exemplo n.º 8
0
        public static void OnBuildStart(AssetBundleBuildConfig config, bool isGen)
        {
            GameResGenerator.ReadGameRes();
            BuildBoy.ClearGameRes(config);
            BuildBoy.CopyLua();
            BuildBoy.GenSpriteRes();
            if (!isGen)
            {
#if UNITY_STANDALONE_WIN
                //UGUIAtlasMaker.GenAtlas();
#endif
                BuildBoy.ChangeUIToAtlas();
            }
            AssetDatabase.Refresh();
            //MyModelGenerater.BatchGenerateRolePrefabs();
            //MonsterPrefabGenerator.BatchGeneratePrefab();
        }
Exemplo n.º 9
0
 // 资源清单处理方法
 #region GameRes
 public static void ClearGameRes(AssetBundleBuildConfig config)
 {
     for (int i = 0; i < config.filters.Count; ++i)
     {
         AssetBundleFilterMain filter = config.filters[i];
         if (filter.valid)
         {
             ClearGameRes(filter.resType);
             if (filter.HasSub())
             {
                 for (int j = 0; j < filter.subFilterList.Count; ++j)
                 {
                     ClearGameRes(filter.subFilterList[j].resType);
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
        void OnGUI()
        {
            bool execBuild = false;

            if (_config == null)
            {
                _config = AssetDatabase.LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
                if (_config == null)
                {
                    _config = CreateInstance <AssetBundleBuildConfig>();
                }
            }

            if (_list == null)
            {
                _list = new ReorderableList(_config.filters, typeof(AssetBundleFilter));
                _list.drawElementCallback = OnListElementGUI;
                _list.drawHeaderCallback  = OnListHeaderGUI;
                _list.draggable           = true;
                _list.elementHeight       = 22;
            }

            //tool bar
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                if (GUILayout.Button("Add", EditorStyles.toolbarButton))
                {
                    _config.filters.Add(new AssetBundleFilter());
                }
                if (GUILayout.Button("Save", EditorStyles.toolbarButton))
                {
                    Save();
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Build", EditorStyles.toolbarButton))
                {
                    execBuild = true;
                }
            }
            GUILayout.EndHorizontal();

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false);

            if (_fileList == null)
            {
                _fileList = new ReorderableList(_config.files, typeof(AssetBundleFilter));
                _fileList.drawElementCallback = OnFileListElementGUI;
                _fileList.drawHeaderCallback  = OnFileListHeaderGUI;
                _fileList.draggable           = true;
                _fileList.elementHeight       = 22;
            }

            //context
            GUILayout.BeginVertical();

            //format
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("DepInfoFileFormat");
                _config.depInfoFileFormat = (AssetBundleBuildConfig.Format)EditorGUILayout.EnumPopup(_config.depInfoFileFormat);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            _list.DoLayoutList();
            GUILayout.EndVertical();

            GUILayout.Space(10);
            _fileList.DoLayoutList();
            EditorGUILayout.EndScrollView();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(_config);
            }

            if (execBuild)
            {
                Build();
            }
        }
 AssetBundleBuildPanel()
 {
     config = LoadConfig();
 }
        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();
        }