Exemple #1
0
    //外部调用、异步加载资源
    public void LoadAsyncAsset(string path, AssetFunc callback)
    {
        if (isLoadedAsset(path))
        {
            callback(loadedList[path]);
            return;
        }

        if (isLoadingAsset(path))
        {
            Debug.LogWarning(string.Format("{0} asset loading!!!", path));
            return;
        }

        if (bundleDependency.ContainsKey(path))
        {
            List<string> dependencies = bundleDependency[path].dependAssets;
            foreach (string dependFile in dependencies)
            {
                if (isLoadedAsset(path) == false)
                {
                    StartCoroutine(LoadAsync(dependFile));
                }
                RefAssets(dependFile);
            }

        }
        StartCoroutine(LoadAsync(path, callback));
        RefAssets(path);
    }
Exemple #2
0
    //外部调用、异步加载资源
    public void LoadAsyncAsset(string path, AssetFunc callback)
    {
        if (isLoadedAsset(path))
        {
            callback(loadedList[path]);
            return;
        }

        if (isLoadingAsset(path))
        {
            Debug.LogWarning(string.Format("{0} asset loading!!!", path));
            return;
        }

        if (bundleDependency.ContainsKey(path))
        {
            List <string> dependencies = bundleDependency[path].dependAssets;
            foreach (string dependFile in dependencies)
            {
                if (isLoadedAsset(path) == false)
                {
                    StartCoroutine(LoadAsync(dependFile));
                }
                RefAssets(dependFile);
            }
        }
        StartCoroutine(LoadAsync(path, callback));
        RefAssets(path);
    }
 private void CharacterCheck(AssetFunc func)
 {
     LoadCharacterData();
     foreach (CharacterData character in data)
     {
         Assert.NotNull(func(character));
     }
 }
 protected void Check(AssetFunc func)
 {
     LoadData();
     foreach (T datum in data)
     {
         object result = func(datum);
         if (result == null)
         {
             Log.Error(datum);
         }
         Assert.NotNull(result);
     }
 }
Exemple #5
0
    private IEnumerator LoadAsync(string path, AssetFunc callback = null)
    {
        if (GameSetting.isEditorModel)
        {
            loadingList.Add(path);
            string fullpath = FullPath(path);
            Object obj      = Resources.LoadAssetAtPath(fullpath, typeof(Object));
            yield return(obj);

            loadedList[path] = obj;

            if (callback != null)
            {
                callback(loadedList[path]);
            }

            loadingList.Remove(path);
        }
        else
        {
            loadingList.Add(path);
            string fullpath = FullPath(path);

            /*
             * WWW bundle = WWW.LoadFromCacheOrDownload(fullpath, 1);
             * yield return bundle;
             * AssetBundle asset = bundle.assetBundle;
             */
            AssetBundle asset = AssetBundle.CreateFromFile(fullpath);
            yield return(asset);

            AssetBundleRequest req = asset.LoadAsync(GetAssetName(path), typeof(Object));
            yield return(req);

            loadedList[path] = req.asset;
            StartCoroutine(UnloadAssetBundle(asset));
            //bundle = null;

            if (callback != null)
            {
                callback(loadedList[path]);
            }

            loadingList.Remove(path);
        }
    }
Exemple #6
0
    private IEnumerator LoadAsync(string path, AssetFunc callback = null)
    {
        if (GameSetting.isEditorModel)
        {
            loadingList.Add(path);
            string fullpath = FullPath(path);
            Object obj = Resources.LoadAssetAtPath(fullpath, typeof(Object));
            yield return obj;

            loadedList[path] = obj;

            if (callback != null)
            {
                callback(loadedList[path]);
            }

            loadingList.Remove(path);
        }
        else
        {
            loadingList.Add(path);
            string fullpath = FullPath(path);
            /*
            WWW bundle = WWW.LoadFromCacheOrDownload(fullpath, 1);
            yield return bundle;
            AssetBundle asset = bundle.assetBundle;
            */
            AssetBundle asset = AssetBundle.CreateFromFile(fullpath);
            yield return asset;

            AssetBundleRequest req = asset.LoadAsync(GetAssetName(path), typeof(Object));
            yield return req;

            loadedList[path] = req.asset;
            StartCoroutine(UnloadAssetBundle(asset));
            //bundle = null;

            if (callback != null)
            {
                callback(loadedList[path]);
            }

            loadingList.Remove(path);
        }
    }