Esempio n. 1
0
    public IEnumerator DownloadPackageWithList(List <string> list)
    {
        if (needDownloadPackageList.Count != 0 || overDownloadPackageList.Count != 0)
        {
            Debug.LogError("Is Have Loader Package!");
            yield break;
        }
        if (list.Count == 0)
        {
            Debug.LogError("Download What?!");
            yield break;
        }
        List <UniGameResourcesPackage> packageList = new List <UniGameResourcesPackage>(8);

        for (int i = 0; i < list.Count; i++)
        {
            UniGameResourcesPackage package = UniGameResources.FindSystemResourcesPackageTable(list[i]);
            if (package == null)
            {
                Debug.LogError(string.Format("not find package:{0}", list[i]));
                yield break;
            }
            packageList.Add(package);
        }
        yield return(StartCoroutine(DownloadPackageWithList(packageList)));
    }
    //打开游戏启动画面
    protected virtual IEnumerator OpenGameBootFace()
    {
        //检测是否有系统启动界面
        if (UniGameResources.FindSystemResourcesPackageTable(UniGameResourcesDefine.DefineAssetBundleName_GameBoot) == null)
        {
            yield break;
        }
        uint guid = UniGameResources.resourcesDownLoadWorker.AllocLoadingAssetObjectGUID();

        yield return(StartCoroutine(UniGameResources.resourcesDownLoadWorker.LoadingAssetObject(UniGameResourcesDefine.DefineAssetBundleName_GameBoot,
                                                                                                UniGameResourcesDefine.GameBoot_AssetBundle_Path, guid, typeof(UnityEngine.GameObject), true)));

        UnityEngine.GameObject obj = UniGameResources.resourcesDownLoadWorker.PutoffAssetObject(guid) as UnityEngine.GameObject;
        SceneControl.gameBootFace = obj.GetComponent <UniGameBootFace>();
    }
    public IEnumerator LoadingAssetObject(string packageName, string assetName, uint assetGuid, Type type, bool isInstantiate)
    {
        UniGameResourcesDownLoader loader = AllocResourcesDownLoader_DontDestroyOnLoad();

        yield return(StartCoroutine(loader.DownloadPackage(packageName)));

        UniGameResourcesPackage package = UniGameResources.FindSystemResourcesPackageTable(packageName);

        if (package == null)
        {
            Debug.LogError(string.Format("not find package:{0}", packageName));
            yield break;
        }
        UnityEngine.Object obj = null;
        package.LockPackage();
        try
        {
            if (isInstantiate)
            {
#if UNITY_4_3 || UNITY_4_6
                obj = GameObject.Instantiate(package.currentAssetBundle.Load(assetName, type));
#else
                obj = GameObject.Instantiate(package.currentAssetBundle.LoadAsset(assetName, type));
#endif
            }
            else
            {
#if UNITY_4_3 || UNITY_4_6
                obj = package.currentAssetBundle.Load(assetName, type);
#else
                obj = package.currentAssetBundle.LoadAsset(assetName, type);
#endif
            }
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.ToString());
        }
        package.UnLockPackage();

        loadingAssetTree.Add(assetGuid, obj);
        ReleaseResourcesDownLoader(loader);
    }