Beispiel #1
0
    public static void SetAssetBundleName(AssetImporter ai)
    {
        string n = Path.GetFileNameWithoutExtension(ai.assetPath);

        n = ALG.EncodeBundleName(n);
        ai.assetBundleName = n;
    }
Beispiel #2
0
    public static void SetAssetBundleName(string path)
    {
        string n = Path.GetFileNameWithoutExtension(path);

        n = ALG.EncodeBundleName(n);
        SetAssetBundleName(path, n);
    }
Beispiel #3
0
        IEnumerator RealLoadAssetBundle(AssetTask assetTask)
        {
            assetTask.abName = ALG.DecodeBundleName(assetTask.abName);
            var dependencies = _assetDependency.GetDependencies(ALG.EncodeBundleName(assetTask.abName));
            var taskArray    = new AssetTask[dependencies.Length];

            for (var i = 0; i < dependencies.Length; i++)
            {
                var task = new AssetTask(dependencies[i], null, null, null, null);
                taskArray[i] = task;
                new Task(RealLoadAssetBundle(task), "AssetBundleManager_" + task.abName);
            }
            var j = 0;

            while (j < taskArray.Length)
            {
                if (taskArray[j].isFinish)
                {
                    j++;
                }
                else
                {
                    yield return(null);
                }
            }
            _assetBundleLoader.LoadAssetBundle(assetTask.abName, (AssetBundle ab) =>
            {
                _assetBundleLoader.GetAssetBundle(assetTask.abName).AddReference();
                assetTask.isFinish = true;
            }, null);
            while (!assetTask.isFinish)
            {
                yield return(null);
            }
        }
Beispiel #4
0
        private void RealUnloadAssetWithName(string name)
        {
            name = ALG.DecodeBundleName(name);
            string[] dependencies = _assetDependency.GetDependencies(ALG.EncodeBundleName(name));
            for (int i = 0; i < dependencies.Length; i++)
            {
                RealUnloadAssetWithName(dependencies[i]);
            }
            var abCache = _assetBundleLoader.GetAssetBundle(name);

            if (null == abCache)
            {
                return;
            }
            abCache.RemoveReference();
            if (0 >= abCache.ReferencesCount)
            {
                releaseList.Add(abCache);
            }
        }
Beispiel #5
0
        IEnumerator RealLoadAssetBundle(AssetBundleCache abCache)
        {
            //foreach(string path in FilePathDefine.loadedPath){
            var paths = FilePathDefine.loadedPath;
            var _path = Path.Combine(paths[0], ALG.EncodeBundleName(abCache.Name));

            if (!File.Exists(_path))
            {
                _path = Path.Combine(paths[1], ALG.EncodeBundleName(abCache.Name));
            }
            var bundleLoadRequest = AssetBundle.LoadFromFileAsync(_path);

            yield return(bundleLoadRequest);

            var myLoadedAssetBundle = bundleLoadRequest.assetBundle;

            abCache.Target = myLoadedAssetBundle;
            abCache.LoadAssetSuccessCallback(myLoadedAssetBundle);
            abCache.isLock = false;
            //}
        }