Ejemplo n.º 1
0
        public static void DeleteAssetBundlesName()
        {
            string        assetBundleName = "";
            List <ABInfo> del             = new List <ABInfo>();

            Object[] selection = Selection.objects; //EditorUtils.SelectObjects();

            foreach (Object s in selection)
            {
                string abPath = AssetDatabase.GetAssetPath(s);
                string folder = EditorUtils.GetLabelsByPath(abPath);
                string name   = CUtils.GetRightFileName(s.name.ToLower());

                if (string.IsNullOrEmpty(folder))
                {
                    assetBundleName = name + "." + Common.ASSETBUNDLE_SUFFIX;
                }
                else
                {
                    assetBundleName = string.Format("{0}/{1}.{2}", folder, name, Common.ASSETBUNDLE_SUFFIX);
                }

                if (s.name.Contains(" "))
                {
                    Debug.LogWarning(s.name + " contains space");
                }
                Debug.Log("delete : " + s.name + " md5 = " + assetBundleName);
                del.Add(new ABInfo(assetBundleName, 0, 0, 0));
            }

            SplitPackage.DeleteStreamingFiles(del); //删除选中对象的ab
        }
Ejemplo n.º 2
0
        public static void GenerateAssetBundlesUpdateFile(string[] allBundles)
        {
            string title = "Generate Update File ";
            string info  = "Compute crc32";

            EditorUtility.DisplayProgressBar(title, info, 0.1f);
            Dictionary <string, object[]> firstCrcDict = new Dictionary <string, object[]>();
            HashSet <string> manualFileList            = new HashSet <string>();
            Dictionary <string, object[]> currCrcDict  = new Dictionary <string, object[]>();
            Dictionary <string, object[]> diffCrcDict  = new Dictionary <string, object[]>();

            #region 读取首包
            bool firstExists = SplitPackage.ReadFirst(firstCrcDict, manualFileList);
            #endregion

            SplitPackage.DeleteSplitPackageResFolder();

            #region 生成校验列表
            SplitPackage.UpdateOutPath = null;
            AssetDatabase.Refresh();
            StringBuilder[] sbs           = SplitPackage.CreateCrcListContent(allBundles, firstCrcDict, currCrcDict, diffCrcDict, manualFileList);
            uint            streaming_crc = SplitPackage.CreateStreamingCrcList(sbs[0]);                          //本地列表
            // System.Threading.Thread.Sleep(1000);
            uint diff_crc = SplitPackage.CreateStreamingCrcList(sbs[1], firstExists, SplitPackage.UpdateOutPath); //增量列表
            // System.Threading.Thread.Sleep(1000);
            CUtils.DebugCastTime("Time CreateStreamingCrcList End");
            #endregion

            #region 生成版本号
            //生成版本号码
            SplitPackage.CreateVersionAssetBundle(diff_crc);
            CUtils.DebugCastTime("Time CreateVersionAssetBundle End");
            #endregion

            #region copy更新文件导出

            SplitPackage.CopyVersionToSplitFolder(diff_crc);

            SplitPackage.CopyChangeFileToSplitFolder(firstExists, firstCrcDict, currCrcDict, diffCrcDict, manualFileList);

            CUtils.DebugCastTime("Time CopyChangeFileToSplitFolder End");

            Debug.LogFormat("streaming_crc={0},diff_crc{1}", streaming_crc, diff_crc);

            Debug.LogFormat(" firstCrcDict={0},currCrcDict={1},diffCrcDict={2},manualFileList={3}", firstCrcDict.Count, currCrcDict.Count, diffCrcDict.Count, manualFileList.Count);

            #endregion

            #region  除手动加载文件
#if (UNITY_ANDROID || UNITY_IOS) //&& !UNITY_EDITOR
            SplitPackage.DeleteStreamingFiles(manualFileList);
#endif
            #endregion

            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 3
0
        public static void BuildAssetBundles()
        {
            CUtils.DebugCastTime("Time HandleUpdateMaterail End");
            EditorUtils.CheckstreamingAssetsPath();
            CUtils.DebugCastTime("Time CheckstreamingAssetsPath End");
            var ab = BuildPipeline.BuildAssetBundles(EditorUtils.GetOutPutPath(), SplitPackage.DefaultBuildAssetBundleOptions, target);

            SplitPackage.CreateStreamingFileManifest(ab);
            CUtils.DebugCastTime("Time BuildPipeline.BuildAssetBundles End");
        }
Ejemplo n.º 4
0
        public static void GenerateAssetBundlesUpdateFile(string[] allBundles)
        {
            string title = "Generate Update File ";
            string info  = "Compute crc32";

            EditorUtility.DisplayProgressBar(title, info, 0.1f);
            Dictionary <string, uint[]> firstCrcDict  = new Dictionary <string, uint[]>();
            HashSet <string>            whiteFileList = new HashSet <string>();
            HashSet <string>            blackFileList = new HashSet <string>();
            Dictionary <string, uint[]> currCrcDict   = new Dictionary <string, uint[]>();
            Dictionary <string, uint[]> diffCrcDict   = new Dictionary <string, uint[]>();

            #region 读取首包
            bool firstExists = SplitPackage.ReadFirst(firstCrcDict, whiteFileList, blackFileList);
            #endregion
            // return ;
            SplitPackage.DeleteSplitPackageResFolder();

            #region 生成校验列表
            SplitPackage.UpdateOutPath = null;
            StringBuilder[] sbs           = SplitPackage.CreateCrcListContent(allBundles, firstCrcDict, currCrcDict, diffCrcDict, whiteFileList, blackFileList);
            uint            streaming_crc = SplitPackage.CreateStreamingCrcList(sbs[0]);                          //本地列表
            System.Threading.Thread.Sleep(1000);
            uint diff_crc = SplitPackage.CreateStreamingCrcList(sbs[1], firstExists, SplitPackage.UpdateOutPath); //增量列表
            System.Threading.Thread.Sleep(1000);
            #endregion

            #region 生成版本号
            //生成版本号码
            SplitPackage.CreateVersionAssetBundle(diff_crc);
            #endregion

            #region copy更新文件导出

            SplitPackage.CopyVersionToSplitFolder(diff_crc);

            SplitPackage.CopyChangeFileToSplitFolder(firstExists, firstCrcDict, currCrcDict, diffCrcDict, whiteFileList, blackFileList);

            Debug.LogFormat("streaming_crc={0},diff_crc{1}", streaming_crc, diff_crc);

            Debug.LogFormat(" firstCrcDict={0},currCrcDict={1},diffCrcDict={2},whiteFileList={3},blackFileList={4}", firstCrcDict.Count, currCrcDict.Count, diffCrcDict.Count, whiteFileList.Count, blackFileList.Count);

            #endregion

            #region  除扩展文件
#if (UNITY_ANDROID || UNITY_IOS) //&& !UNITY_EDITOR
            if (whiteFileList.Count > 0)
            {
                List <string> del = new List <string>();
                foreach (var kv in currCrcDict)
                {
                    if (!whiteFileList.Contains(kv.Key))
                    {
                        del.Add(kv.Key);
                    }
                }
                SplitPackage.DeleteStreamingFiles(del);//保留白名单
            }
            else
            {
                SplitPackage.DeleteStreamingFiles(blackFileList);
            }
#endif
            #endregion

            EditorUtility.ClearProgressBar();
        }