Example #1
0
        public void RemoveObectsFromCacheTest(string input, string output)
        {
            List <string> inputs = new List <string> {
                "test1", "test2", "test3"
            };

            // clear cache
            Caching.ClearCache();
            // set data in the cache
            foreach (string s in inputs)
            {
                s.SetObjectInCache <string>(5, s);
            }

            input.SetObjectInCache <string>(5, input);

            List <CacheObject> allCache = Caching.GetAllCache();

            Assert.AreEqual(inputs.Count() + 1, allCache.Count());

            // change the cached item to something new
            inputs.RemoveObjectsFromCache();
            // check cached item
            List <CacheObject> newCache   = Caching.GetAllCache();
            string             cachedItem = newCache.Where(w => w.Key.ToLower() == inputs.FirstOrDefault().ToLower()).Select(s => s.Value.ToString()).FirstOrDefault();

            Assert.IsNull(cachedItem);
            Assert.AreEqual(newCache.Count(), 1);
        }
Example #2
0
    /// <summary>
    /// build选中的目标,不使用依赖,强制打包目标所有依赖
    /// </summary>
    public static void ExportSelect(BuildTarget target)
    {
        Caching.ClearCache();
        Object[] selectedAssets = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        string outPath = PathUtils.GetAssetOutPath((int)target);

        if (!Directory.Exists(outPath))
        {
            Directory.CreateDirectory(outPath);
        }

        foreach (Object asset in selectedAssets)
        {
            string targetPath = PathUtils.GetAssetOutPath((int)target) + asset.name + ".assetbundle";

            if (BuildPipeline.BuildAssetBundle(asset, null, targetPath, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, EditorUserBuildSettings.activeBuildTarget))
            {
                Debug.Log(asset.name + ": create assetbundle success!!!");
            }
            else
            {
                Debug.Log(asset.name + ": create assetbundle failed!!!");
            }
        }
        AssetDatabase.Refresh();
    }
    private void Start()
    {
        if (clearAssetBundlesInCache)
        {
            Caching.ClearCache();
        }

        string manifestURL = "";

        if (isLocal)
        {
            manifestURL = "file://" + Application.streamingAssetsPath + "/" + localManifestPath;
        }
        else
        {
            manifestURL = remoteManifestURL;
        }

        //remoteManifestURL = manifestURL;

        // AssetBundleManager初期化
        remoteManifestURL = "http://keycert.site/test/Unknown/Unknown";
        AssetBundleManager.Initialize(remoteManifestURL, (bool isComplete) =>
        {
            // ダウンロード対象のAssetBundleのファイルサイズ
            AssetBundleManager.GetDownloadFileSize(downloadAssetBundles, (ulong b, string e) =>
            {
                output = "Downloadable AssetBundles file size = " + b + " Bytes.";
            });
        });
    }
Example #4
0
 public static void ClearLocalDataAndPrefs()
 {
     PlayerPrefs.DeleteAll();
     Caching.ClearCache();
     ClearLocalData();
     Save();
 }
Example #5
0
    // Use this for initialization
    void Start()
    {
        Caching.ClearCache();
        int    FullPkgVer  = Convert.ToInt32(BoyApp.GetTextAssetsFromResouces("pkgver"));
        string LocalPkgVer = BoyApp.GetTextAssetsFromPersistent("pkgver");

        if (LocalPkgVer != null && Convert.ToInt32(LocalPkgVer) < FullPkgVer)
        {
            Caching.ClearCache();
            File.Delete(Application.persistentDataPath + "/loadfileinfo.txt");
            File.Delete(Application.persistentDataPath + "/loadfilever.txt");
            File.Delete(Application.persistentDataPath + "/pkgver");
        }

        if (File.Exists(Application.persistentDataPath + "/loadfileinfo.txt"))
        {
            BoyApp.localFileInfo = (Dictionary <string, string>)JsonConvert.DeserializeObject(File.ReadAllText(Application.persistentDataPath + "/loadfileinfo.txt"), typeof(Dictionary <string, string>));
        }
        if (File.Exists(Application.persistentDataPath + "/loadfilever.txt"))
        {
            BoyApp.localFileVer = (Dictionary <string, int>)JsonConvert.DeserializeObject(File.ReadAllText(Application.persistentDataPath + "/loadfilever.txt"), typeof(Dictionary <string, int>));
        }

        StartCoroutine(LoadAssetBundleManifest());
    }
Example #6
0
    public static void CreateAllAssetBundles(bool isDisplayDialog, bool isSelect = false)
    {
        if (!isSelect)
        {
            SetMainAssetBundleName();
            EditorUtility.DisplayProgressBar("正在启动打Assetbundle逻辑,请稍等", "正在启动打Assetbundle逻辑,请稍等...", 1);
            Caching.ClearCache();
            string path = uiAssetBundlesPath + (isSelect ? "Select/" : "");
            if (string.IsNullOrEmpty(path))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            Utility.DetectCreateDirectory(path);
            //打包资源
            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
            EditorUtility.ClearProgressBar();


            if (isDisplayDialog)
            {
                EditorUtility.DisplayDialog("完成", "完成", "确定");
            }
        }
        else
        {
            SetUIAssetBundleSelect();
        }
    }
Example #7
0
    /**
     * Parse file and render buildings when scene starts
     */
    private void Start()
    {
        Caching.ClearCache();
        //hide and lock cursor into center
        UiUtils.HideCursor();

        TutorialUtils.InitTutorial(TutorialCanvas, Settings);
        BuildingPickerCanvas.SetActive(false);
        ExitCanvasDialog.SetActive(false);

        //load XML file tags
        var xmlFile = new XmlDocument();

        //load file
        xmlFile.Load(FileUtils.GetFullMapPath(Map.MapName));
        //get node and way tags
        var nodeTags = xmlFile.SelectNodes(".//node");
        var wayTags  = xmlFile.SelectNodes(".//way");
        //cache IDs in node tag for coordinate pairing
        var nodeTagIds = CacheNodeTagIds(nodeTags);

        //parse building and roads
        var buildings      = BuildingLoader.Get().LoadFile(nodeTags, nodeTagIds, wayTags);
        var roads          = RoadLoader.Get().LoadFile(nodeTags, nodeTagIds, wayTags);
        var trees          = TreeLoader.Get().LoadFile();
        var mapMiddlePoint = GetMiddlePoint(buildings, roads);

        //download elevation data
        AltitudeLoader.Get().SetAltitude(TerrainUtils.GetLatLngGrid(mapMiddlePoint));
        //render terrain, buildings, roads etc.
        StartCoroutine(RenderObjects(mapMiddlePoint, buildings, roads, trees));
    }
Example #8
0
 IEnumerator GetAssetBundle()
 {
     Caching.ClearCache();
     g.progressMgr.UpdateImageProgress(-1);
     using (uwr = UnityWebRequestAssetBundle.GetAssetBundle(url))
     {
         AsyncOperation request = uwr.SendWebRequest();
         while (!request.isDone)
         {
             g.progressMgr.UpdateImageProgress(uwr.downloadProgress);
             yield return(null);
         }
         g.progressMgr.UpdateImageProgress(2);
         if (uwr.isNetworkError || uwr.isHttpError)
         {
             Debug.Log(uwr.error);
         }
         else
         {
             AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(uwr);
             UpdateNextAssetNameCurrent(assetBundle);
             goAssetBundle = Instantiate(assetBundle.LoadAsset(assetNameCurrent)) as GameObject;
             g.assetMgr.SwitchToExternalAssets(goAssetBundle);
             assetBundle.Unload(false);
             uwr = null;
         }
     }
 }
Example #9
0
    void OnGUI()
    {
        // 信息显示区域
        GUI.BeginGroup(new Rect(10f, 10f, 280f, 250f), "", "box");
        EditorGUILayout.BeginVertical();

        GUILayout.Label("是否激活: " + Caching.compressionEnabled);
        GUILayout.Label("是否准备好: " + Caching.ready);
        GUILayout.Label("缓存总容量: " + Caching.maximumAvailableDiskSpace / (1024f * 1024f) + "M");
        GUILayout.Label("已使用: " + Caching.spaceOccupied / (1024f * 1024f) + "M");
        GUILayout.Label("还剩余: " + Caching.spaceFree / (1024f * 1024f) + "M");
        GUILayout.Label("空闲剩余时间: " + (Caching.expirationDelay / 3600f) + "h");

        // 特定资源检索
        GUILayout.Label("------------------------------------------------");
        GUILayout.Label("URL");
        url = EditorGUILayout.TextField(url, GUILayout.Width(200), GUILayout.Height(20));
        GUILayout.Label("VersionNum");
        version = EditorGUILayout.TextField(version, GUILayout.Width(200), GUILayout.Height(20));
        if (GUI.Button(new Rect(210f, 150f, 50f, 50f), "检测"))
        {
            exist = Caching.IsVersionCached(url, System.Convert.ToInt32(version));
        }
        GUI.Label(new Rect(0, 210, 200, 20), "该资源是否存在: " + exist);
        GUI.Label(new Rect(0, 230, 300, 20), "------------------------------------------------");

        EditorGUILayout.EndVertical();
        GUI.EndGroup();

        if (GUI.Button(new Rect(10, 280f, 280f, 50f), "清空缓存"))
        {
            Caching.ClearCache();
        }
    }
Example #10
0
    void OnDeleteUserPopupResult(string result)
    {
        if (result == "yes")
        {
            PlayerPrefs.DeleteAll();
            for (int i = 0; i < Battle.battleGroupList.Count; i++)
            {
                SaveLoadManager.Clear(SaveType.Battle, Battle.battleGroupList[i].battleType);
            }

            for (int i = 0; i < TerritoryManager.Instance.myPlaceList.Count; i++)
            {
                SaveLoadManager.Clear(SaveType.Place, TerritoryManager.Instance.myPlaceList[i].placeID + User.Instance.userID);
            }

            Caching.ClearCache();

#if UNITY_EDITOR
            Debug.Log("계정 삭제 재시작해주세요.");
#endif

#if !UNITY_EDITOR
            Application.Quit();
#endif
        }
    }
Example #11
0
        private static void OnPlayModeStateChanged(PlayModeStateChange state)
        {
            switch (state)
            {
            case PlayModeStateChange.ExitingEditMode:
            {
                if (GetAutoRebuildEnabled() && AssetBundlesBuilder.CheckAssetBundlesExist(true))
                {
                    AssetBundlesBuilder.Build(GetLocalBuildTargetTyped(), BuildAssetBundleOptions.StrictMode, false);
                }
                return;
            }

            case PlayModeStateChange.EnteredPlayMode:
            {
                if (GetAutoRebuildEnabled() && AssetBundlesBuilder.CheckAssetBundlesExist(false))
                {
                    Debug.Log("AssetBundles: Bundles were built before Playing");
                }
                break;
            }

            case PlayModeStateChange.ExitingPlayMode:
            {
                if (GetCleanCacheAfterPlayEnabled())
                {
                    AssetBundle.UnloadAllAssetBundles(false);
                    Caching.ClearCache();
                    Debug.Log("AssetBundles: Cache cleaned");
                }
                break;
            }
            }
        }
    static void ClearCached()
    {
        AssetBundle.UnloadAllAssetBundles(true);
        bool success = Caching.ClearCache();

        Debug.Log("CLEAR CACHE: " + success);
    }
        /// <summary>
        ///  初始化方法 一般只执行一次
        /// </summary>
        /// <param name="path"></param>
        public void InitWithRootPath(string resourceRootPath, string resourceSpareRootPath, string mainfestName)
        {
            print("正式资源地址" + resourceRootPath);
            print("备用资源地址" + resourceSpareRootPath);

            Caching.ClearCache();

            if (!Directory.Exists(resourceRootPath))
            {
                Directory.CreateDirectory(resourceRootPath);
            }

            if (!string.IsNullOrEmpty(resourceRootPath) && !string.IsNullOrEmpty(resourceSpareRootPath))
            {
                if (!string.Equals(resourceRootPath.Substring(resourceRootPath.Length - 1), @"/"))
                {
                    resourceRootPath = resourceRootPath + @"/";
                }

                if (!string.Equals(resourceSpareRootPath.Substring(resourceSpareRootPath.Length - 1), @"/"))
                {
                    resourceSpareRootPath = resourceSpareRootPath + @"/";
                }

                ResourceRootPath      = resourceRootPath;
                ResourceSpareRootPath = resourceSpareRootPath;
                MainfestName          = mainfestName;
                GetAssetBundleManifest();
            }
        }
Example #14
0
        private static void CreateMultipleAssetBundle()
        {
            Caching.ClearCache();

            if (Selection.objects.Length > 0)
            {
                //显示保存窗口
                string path = EditorUtility.SaveFilePanel("Create Multiple AssetBundle:", "", "New AssetBundle", "unity3d");

                if (path.Length > 0)
                {
                    UnityEngine.Object[] SelectedAsset = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);

                    foreach (UnityEngine.Object obj in SelectedAsset)
                    {
                        Debug.Log("Create AssetBunldes name :" + obj);
                    }

                    //这里注意第二个参数就行
                    if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.WebGL))
                    {
                        AssetDatabase.Refresh();
                    }
                }
            }
        }
Example #15
0
 //----------------------------------------------------------------------------
 public static void Clear()
 {
     ClearExportPath();
     Caching.ClearCache();
     buildList.Clear();
     m_missingFont.Clear();
 }
        private static void createAssetBundle(string buildPath, BuildTarget buildTarget, BundleBuildSettings settings)
        {
            Caching.ClearCache();
            ///默认的路径
            string Path = buildPath + "/AssetBundles";

            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }

            ClearDirectory(Path);

            if (settings != null)
            {
                AssetBundleBuild[] builds = settings.GetAssetBundleBuilds();
                if (builds != null)
                {
                    BuildPipeline.BuildAssetBundles(Path, builds, BuildAssetBundleOptions.ChunkBasedCompression, buildTarget);
                }
            }
            else
            {
                BuildPipeline.BuildAssetBundles(Path, BuildAssetBundleOptions.ChunkBasedCompression, buildTarget);
            }
        }
    //-------------------------------------------------------------------------
    void _packAssetBundleCompressAll(string target_path)
    {
        _setCurrentBuildTargetGroupPlatform();
        EditorUserBuildSettings.SwitchActiveBuildTarget(mCurrentBuildTargetGroupPlatform, mCurrentBuildTargetPlatform);
        deleteFile(mTargetPlatformRootPath);

        Caching.ClearCache();

        mListAllPkgSingleABFile.Clear();
        _getAllPkgSingleFiles(mAssetBundleResourcesPkgSinglePath);
        mListAllPkgFoldABFold.Clear();
        _getAllPkgFoldFold(mAssetBundleResourcesPkgFoldPath);

        _pakABSingle();
        _pakABFold();

        if (Directory.Exists(mRowAssetPath))
        {
            copyFile(mRowAssetPath, target_path, "Assets/", mDoNotCopyDir);
        }

        //if (Directory.Exists(mConfigPath))
        //{
        //    copyFile(mConfigPath, target_path, "Assets/");
        //}

        Debug.Log("裸资源复制完毕!");
    }
Example #18
0
File: BuildAB.cs Project: GF47/GRT
        private static void BuildAll(BuildTarget target)
        {
            Caching.ClearCache();

            string[]           assetbundleNames = AssetDatabase.GetAllAssetBundleNames();
            AssetBundleBuild[] abBuilds         = new AssetBundleBuild[assetbundleNames.Length];
            for (int i = 0; i < abBuilds.Length; i++)
            {
                AssetBundleBuild build = new AssetBundleBuild
                {
                    assetNames         = AssetDatabase.GetAssetPathsFromAssetBundle(assetbundleNames[i]),
                    assetBundleVariant = string.Empty,// TODO 添加LOD时会需要,或者根据机型性能区分
                    assetBundleName    = string.Format("{0}.{1}", assetbundleNames[i], AB_FILE_EXTENSION)
                };

                abBuilds[i] = build;
            }

            string outputPath = CreateABDirectory(target, Application.dataPath.Substring(0, Application.dataPath.Length - 7) + "/" + ASSETBUNDLES_ROOT_DIRECTORY);

            BuildPipeline.BuildAssetBundles(outputPath, abBuilds, BuildAssetBundleOptions.ChunkBasedCompression, target);
            AssetDatabase.Refresh();

            CopyAssetsMapFileTo(outputPath, target);
        }
Example #19
0
    static async void CreateSceneC()
    {
        //清空一下缓存  
        Caching.ClearCache();
        string o_path   = EditorUtility.SaveFilePanel("Save Resource", "Assets/StreamingAssets", "Assets", "unity3d");
        int    index    = o_path.LastIndexOf('/');
        string o_folder = o_path.Substring(0, index);

        index++;
        string o_file = o_path.Substring(index, o_path.Length - index);

        if (o_path.Length != 0)
        {
            List <string> names = new List <string>();
            var           o     = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets);
            foreach (UnityEngine.Object obj in o)
            {
                string filePath = AssetDatabase.GetAssetPath(obj);
                if (filePath.IndexOf(".unity") > 0)
                {
                    names.Add(filePath);
                }
            }
            BuildPipeline.BuildPlayer(names.ToArray(), o_path, BuildTarget.StandaloneWindows,
                                      BuildOptions.BuildAdditionalStreamedScenes | BuildOptions.UncompressedAssetBundle);
            var decoder = new Decoder();
            await Task.Run(() => { decoder.DecompressFile(o_path, o_path + ".lzma"); });

            AssetDatabase.Refresh();
            Debug.Log("打包完成");
        }
    }
Example #20
0
    public IEnumerator DownloadAssetBundle(string bundle)
    {
        //WWW www = WWW.LoadFromCacheOrDownload("file:///" + Application.dataPath + "/AssetBundles/octave1.unity3d", 0);
        //WWW www = WWW.LoadFromCacheOrDownload("https://www.dropbox.com/s/9kkx8utmt8qj3f5/octave1.unity3d?dl=1", 0);
        if (cachedBundle.ContainsKey(bundle))
        {
            downloadBundle = cachedBundle[bundle];
        }
        else
        {
            Caching.ClearCache();
            //WWW www = WWW.LoadFromCacheOrDownload("https://www.dropbox.com/s/ygnfqwjjealjjlj/octave5?dl=1", 0);
            //yield return www;
            //downloadBundle = www.assetBundle;
            if (bundle.Contains("http"))
            {
                using (var uwr = new UnityWebRequest(bundle, UnityWebRequest.kHttpVerbGET))
                {
                    uwr.downloadHandler = new DownloadHandlerAssetBundle(bundle, 0);
                    yield return(uwr.SendWebRequest());

                    downloadBundle = DownloadHandlerAssetBundle.GetContent(uwr);
                }
            }
            else
            {
                downloadBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, bundle));
            }
            cachedBundle.Add(bundle, downloadBundle);
        }
        yield return(null);
    }
        protected override void OnClick()
        {
            base.OnClick();

            if (!CocoDebugSettingsData.Instance.IsGodModeEnabled)
            {
                return;
            }

            PlayerPrefs.DeleteAll();
            PlayerPrefs.Save();
#if UNITY_2017_1_OR_NEWER
            Caching.ClearCache();
#else
            Caching.CleanCache();
#endif
            string pPath = Application.persistentDataPath + "/DB/";
            if (System.IO.Directory.Exists(pPath))
            {
                System.IO.Directory.Delete(pPath, true);
            }

            if (nameText != null)
            {
                nameText.text = "Restart";
            }

            UnityEngine.EventSystems.EventSystem.current.enabled = false;
        }
Example #22
0
 void OnLevelLoaded(Scene scene, LoadSceneMode mode = LoadSceneMode.Single)
 {
     App.MgrTool.YieldMethod(0.3f, () => { m_Loading = false; });
     Caching.ClearCache();
     Resources.UnloadUnusedAssets( );
     System.GC.Collect( );
 }
Example #23
0
        public override IEnumerator Start()
        {
            Caching.ClearCache();
            Global.Initialize();
            MVersion           versions = new MVersion();
            SUser              sUser    = Global.SUser;
            List <IEnumerator> list     = new List <IEnumerator>();

            list.Add(sUser.Download(TileAsset.Url, versions.tile, (AssetBundle assetbundle) => {
                TileAsset.assetbundle = assetbundle;
                TileCacher.Instance.Reset(TileAsset.Data.tiles);
                TileAsset.Clear();
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.mapUrl, versions.map, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.map = assetbundle;
            }, false));

            /*list.Add(sUser.Download(ConstantAsset.Url, versions.constant, (AssetBundle assetbundle) => {
             *  ConstantAsset.assetbundle = assetbundle;
             *  Global.Constant = ConstantAsset.Data.constant;
             * }));*/
            Debug.Log("Start");
            for (int i = 0; i < list.Count; i++)
            {
                Debug.Log(i + "/" + list.Count);
                yield return(this.StartCoroutine(list[i]));
            }
            Debug.Log("Start Over");
            loadComplete = true;
        }
        protected override void OnRuntimeSetup()
        {
#if ENABLE_CACHING
            Caching.ClearCache();
#endif
            Assert.IsNull(m_Addressables);
        }
Example #25
0
        // Load AssetBundleManifest.
        static public AssetBundleLoadManifestOperation Initialize()
        {
#if UNITY_EDITOR
            Log(LogType.Info, "Simulation Mode: " + (SimulateAssetBundleInEditor ? "Enabled" : "Disabled"));
#endif

            var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
            DontDestroyOnLoad(go);

#if UNITY_EDITOR
            // If we're in Editor simulation mode, we don't need the manifest assetBundle.
            if (SimulateAssetBundleInEditor)
            {
                return(null);
            }
#endif

#if UNITY_EDITOR
            if (CleanCacheOnPlay)
            {
                Log(LogType.Info, "AssetBundleManager cleaned local cache.");
#if UNITY_2017_1_OR_NEWER
                Caching.ClearCache();
#else
                Caching.CleanCache();
#endif
            }
#endif

            LoadAssetBundle(Settings.CurrentSetting.ManifestFileName, true);
            var operation = new AssetBundleLoadManifestOperation(Settings.CurrentSetting.ManifestFileName, "AssetBundleManifest", typeof(AssetBundleManifest));
            m_InProgressOperations.Add(operation);
            return(operation);
        }
Example #26
0
    IEnumerator LoadAsset()
    {
        string url = Application.streamingAssetsPath + "/sample";

        Debug.Log("Loading AssetBundle");
        Caching.ClearCache();
        WWW www = WWW.LoadFromCacheOrDownload(url, 0);

        yield return(www);

        AssetBundle bundle = www.assetBundle;

        StartCoroutine(LoadAssetInternal(bundle));

        Debug.Log("Destroying GameObject");
        DestroyObject();
        yield return(new WaitForSeconds(0.1f));

        GC.Collect();
        yield return(new WaitForSeconds(0.1f));

        Debug.Log("UnloadUnusedAssets");
        Resources.UnloadUnusedAssets();
        yield return(null);

        //yield return new WaitForSeconds(2.0f);

        Debug.Log("Load from AssetBundle again");
        StartCoroutine(LoadAssetInternal(bundle));
    }
Example #27
0
 public static void CleanCache()
 {
     Caching.ClearCache();
     PlayerPrefs.DeleteAll();
     PlayerPrefs.Save();
     CleanModels();
 }
Example #28
0
 public static bool PackageAssetBundle(BuildTarget buildTarget)
 {
     Caching.ClearCache();
     string[] dirs = new string[] {
         SAAppConfig.DataDir,//数据表
         //SAAppConfig.TextureDir,//图片
         //SAAppConfig.MaterialDir,//材质
         //SAAppConfig.PrefabFontAtlasDir,//字体
         SAAppConfig.ParticleDir,    //粒子
         SAAppConfig.SoundDir,       //音效
         SAAppConfig.PrefabAtlasDir, //图集
         SAAppConfig.ModelDir,       //模型预置
         //SAAppConfig.FBXDir,//动作文件
         SAAppConfig.PrefabUIDir,    //UI预置
         SAAppConfig.LuaByteDir      //Lua
     };
     string[] extNames = new string[] {
         "*.*",//数据表
         //"*.png;*.jpg",//图片
         //"*.mat",//材质
         //"*.*",//字体
         "*.prefab",  //粒子
         "*.prefab",  //音效
         "*.prefab",  //图集
         "*.prefab;", //模型预置
         //"*.prefab",//"*.FBX;*.fbx",//fbx动作文件
         "*.prefab",  //UI预置
         "*.bytes"
     };               //Lua
     return(CreateAssetBundle.Execute(buildTarget, BuildAssetBundleOptions.DeterministicAssetBundle
                                      | BuildAssetBundleOptions.ChunkBasedCompression, "", dirs, extNames));
 }
Example #29
0
    IEnumerator TestLoadAllAssetsAsync()
    {
        foreach (var reqInfo in reqs)
        {
            var ab = DownloadHandlerAssetBundle.GetContent(reqInfo.request);

            var assets = ab.GetAllAssetNames();

            reqInfo.ab = ab;
            reqInfo.assetsInfo.Clear();

            float time   = Time.realtimeSinceStartup;
            var   loadOp = ab.LoadAllAssetsAsync();
            reqInfo.assetsInfo.Add(new ABReqInfo.AssetReqInfo {
                assetName = ab.name, loadOp = loadOp
            });
            time       = Time.realtimeSinceStartup - time;
            logBuffer += $"LoadAllAssetsAsync() {ab.name}... time: {time * 1000}ms\n";
        }

        yield return(AsyncLoadAllAssets());

        yield return(Resources.UnloadUnusedAssets());

        Caching.ClearCache();
    }
Example #30
0
        public void RemoveAllWildcardTest(string itemName1, string itemName2, string itemName3, string wildcard,
                                          string input1, string input2, string input3, int output1, int output2, int output3)
        {
            // clear cache
            Caching.ClearCache();

            for (int i = 0; i < 5; i++)
            {
                $"{i}{itemName1}".SetObjectInCache <string>(5, $"{i} - {input1}");
                $"{i}{itemName2}".SetObjectInCache <string>(5, $"{i} - {input2}");
                $"{i}{itemName3}".SetObjectInCache <string>(5, $"{i} - {input3}");
            }

            List <CacheObject> allCache = Caching.GetAllCache();
            int count = allCache.Where(w => w.Key.ToLower().Contains(itemName1.ToLower())).Count();

            Assert.AreEqual(output1, count);

            itemName1.RemoveAllWildcard();

            allCache = Caching.GetAllCache();
            count    = allCache.Where(w => w.Key.ToLower().Contains(itemName2.ToLower())).Count();
            Assert.AreEqual(output2, count);

            wildcard.RemoveAllWildcard();

            allCache = Caching.GetAllCache();
            count    = allCache.Count();
            Assert.AreEqual(output3, count);
        }