コード例 #1
0
ファイル: BundleManager.cs プロジェクト: zhlikezhz/Game
    //外部调用、异步加载资源
    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);
    }
コード例 #2
0
ファイル: BundleManager.cs プロジェクト: zhlikezhz/Game
    //外部调用、异步加载资源
    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);
    }
コード例 #3
0
 private void CharacterCheck(AssetFunc func)
 {
     LoadCharacterData();
     foreach (CharacterData character in data)
     {
         Assert.NotNull(func(character));
     }
 }
コード例 #4
0
 protected void Check(AssetFunc func)
 {
     LoadData();
     foreach (T datum in data)
     {
         object result = func(datum);
         if (result == null)
         {
             Log.Error(datum);
         }
         Assert.NotNull(result);
     }
 }
コード例 #5
0
ファイル: BundleManager.cs プロジェクト: zhlikezhz/Game
    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);
        }
    }
コード例 #6
0
ファイル: BundleManager.cs プロジェクト: zhlikezhz/Game
    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);
        }
    }