Ejemplo n.º 1
0
 /// <summary>
 /// 测试销毁一个场景中的所有资源
 /// </summary>
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         AssetBundleMgr.GetInstance().DisposeAllAssets(_ScenesName_1);
     }
 }
Ejemplo n.º 2
0
        /*
         * @brief 之所以是有这些接口,是为了在启动时进行使用,加快启动速度,其他地方严禁调用这里的方法
         */
        public AssetBundle SyncLoadAssetBundle(string assetBundleName)
        {
            var path = AssetBundleMgr.GetInstance().GetAssetBundleLocalPath(assetBundleName, "", true);
            var ab   = AssetBundle.LoadFromFile(path, 0, (ulong)computeBundleOffset(assetBundleName));

            return(ab);
        }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         AssetBundleMgr.GetInstance().Dispose(sceneName);
     }
 }
Ejemplo n.º 4
0
    void OnGUI()
    {
        //if can destroy dependence asset
        if (GUI.Button(new Rect(0, 0, 100, 40), "Clean Common"))
        {
            AssetBundleMgr.UnLoadAssetBundle("common");
        }
        //still can't destroy dependence asset
        if (GUI.Button(new Rect(0, 50, 100, 40), "Clean test"))
        {
            AssetBundleMgr.UnLoadAssetBundle("test");
        }
        //destroy "test2", also destroy destroy dependence
        if (GUI.Button(new Rect(0, 100, 100, 40), "Clean test2"))
        {
            AssetBundleMgr.UnLoadAssetBundle("test2");
        }
        if (GUI.Button(new Rect(0, 150, 100, 40), "load"))
        {
            AssetBundle t1   = AssetBundleMgr.GetAssetBundle("test");
            Object      cube = t1.LoadAsset("Cube");
            GameObject  go   = Instantiate(cube) as GameObject;
            go.transform.position = Vector3.left;

            AssetBundle t2     = AssetBundleMgr.GetAssetBundle("test2");
            Object      sphere = t2.LoadAsset("sphere");
            Instantiate(sphere);
        }
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        uiRoot = GameObject.Find("Canvas");
        Button startButton = uiRoot.transform.Find("Button").gameObject.GetComponent <Button>();

        startButton.onClick.AddListener(() =>
        {
            GameObject uiLoginPanl = AssetBundleMgr.GetInstance().LoadAssetFromStreamingAsset <GameObject>("uiLoginPanel");
            GameObject uiLoginObj  = GameObject.Instantiate(uiLoginPanl);
            uiLoginObj.transform.SetParent(uiRoot.transform, false);

            var bundle = AssetBundleMgr.LoadFromStreamingAssetPath("Main");
            SceneManager.LoadScene("Main");

            AssetBundleMgr.LoadFromWWWLocalAsync("uiLoginPanel", (obj) =>
            {
                GameObject go = obj.LoadAsset <GameObject>("uiLoginPanel");
                obj.Unload(false);
            }, 1);

            AssetBundleMgr.LoadFromWWWCacheOrDownloadAsync(Path.Combine(AssetBundleMgr.wwwStreamingAssetPath, "uiLoginPanel"), (obj) =>
            {
                GameObject go = obj.LoadAsset <GameObject>("uiLoginPanel");
                obj.Unload(false);
            }, 2);

            AssetBundleMgr.LoadFromWebRequestAsync(Path.Combine(AssetBundleMgr.wwwStreamingAssetPath, "uiLoginPanel"), (obj) =>
            {
                GameObject go = obj.LoadAsset <GameObject>("uiLoginPanel");
                obj.Unload(false);
            }, 1);
        });
    }
Ejemplo n.º 6
0
        public override long ComputeSize(IResourceLocation location, ResourceManager resourceManager)
        {
            AssetBundleEncryptRequestOptions m_Options;
            var id = resourceManager == null ? location.InternalId : resourceManager.TransformInternalId(location);

            if (!ResourceManagerConfig.IsPathRemote(id))
            {
                return(0);
            }
            string bundleName = Path.GetFileName(id);

            m_Options = location.Data as AssetBundleEncryptRequestOptions;
            var path = AssetBundleMgr.GetInstance().TransformAssetBundleLocation(id, bundleName, m_Options.Hash);

            if (File.Exists(path) || !ResourceManagerConfig.IsPathRemote(path))
            {
                //如果文件存在  情况 1、Editor模式下文件存在  2、persistent下的文件存在  3、streaming asset目录下
                return(0);
            }
            if (AssetBundleMgr.GetInstance().IsCached(bundleName, m_Options.Hash))
            {
                return(0);
            }
            return(BundleSize);
        }
Ejemplo n.º 7
0
 public static AssetBundleMgr GetInstance()
 {
     if (_instance == null)
     {
         _instance = new GameObject("_AssetBundleMgr").AddComponent <AssetBundleMgr>();
     }
     return(_instance);
 }
Ejemplo n.º 8
0
    private void LoadAssetComplete()
    {
        AssetBundle.LoadFromFile(PDPath + $"game.assetbundle");
        SceneManager.LoadScene("Game");
        GameObject obj = AssetBundleMgr.LoadBundle <GameObject>("cube");

        Instantiate(obj);
    }
Ejemplo n.º 9
0
 public static AssetBundleMgr GetInstance()
 {
     if (Instance == null)
     {
         Instance = new AssetBundleMgr();
     }
     return(Instance);
 }
Ejemplo n.º 10
0
        //下载更新资源
        public ETTask <Dictionary <string, string> > CheckUpdateContent(List <string> keys, int iMergeMode)
        {
            Addressables.MergeMode mergeMode             = (Addressables.MergeMode)iMergeMode;
            ETTask <Dictionary <string, string> > result = ETTask <Dictionary <string, string> > .Create();

            var handle = Addressables.LoadResourceLocationsAsync(keys, mergeMode);

            handle.Completed += (res) =>
            {
                if (handle.Status == AsyncOperationStatus.Succeeded)
                {
                    if (handle.Result != null && handle.Result.Count > 0)
                    {
                        var downlocations = handle.Result;

                        string bundleName3;
                        string path;
                        AssetBundleRequestOptions data;
                        var needLoadInfo = new Dictionary <string, string>();
                        if (downlocations != null && downlocations.Count > 0)
                        {
                            foreach (var item in downlocations)
                            {
                                if (item.HasDependencies)
                                {
                                    foreach (var dep in item.Dependencies)
                                    {
                                        bundleName3 = Path.GetFileName(dep.InternalId);
                                        if (dep.Data != null)
                                        {
                                            data = dep.Data as AssetBundleRequestOptions;
                                            path = AssetBundleMgr.GetInstance().TransformAssetBundleLocation(dep.InternalId, bundleName3, data.Hash);
                                            if (UnityEngine.ResourceManagement.Util.ResourceManagerConfig.ShouldPathUseWebRequest(path))
                                            {
                                                needLoadInfo[bundleName3] = data.Hash;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        result.SetResult(needLoadInfo);
                    }
                    else
                    {
                        result.SetResult(null);
                    }
                }
                else
                {
                    result.SetResult(null);
                }
                Addressables.Release(handle);
            };
            return(result);
        }
Ejemplo n.º 11
0
    public void LoadComplete(string abName)
    {
        //2、提取资源
        UnityEngine.Object tmpObj = AssetBundleMgr.GetInstance().LoadAsset(sceneName, abName, assetName, true);

        if (tmpObj)
        {
            Instantiate(tmpObj);
        }
    }
Ejemplo n.º 12
0
 /// <summary>
 /// (回调函数)所有AB包加载完成
 /// </summary>
 /// <param name="abName">AssetBundle 包名</param>
 void LoadAllAssetBundleComplete(string abName)
 {
     Debug.Log("所有基于AB包的引用与依赖关系包集合,已经全部加载完毕。 abName="+abName);
     //加载资源
     GameObject tmpGO = (GameObject)AssetBundleMgr.GetInstance().LoadAsset(_ScenesName_1, _AssetBundleName_1, _AssetName_1, true);
     if (tmpGO)
     {
         Instantiate(tmpGO);
     }
 }
Ejemplo n.º 13
0
        private static bool AddUnitySOPath(List <string> soFileNameList)
        {
            if (soFileNameList == null)
            {
                return(false);
            }
            string unityEditorPath = AssetBundleMgr.GetUnityEditorPath();

            if (string.IsNullOrEmpty(unityEditorPath))
            {
                if (m_IsDebugLog)
                {
                    Debug.LogError("请增加UnityEditor环境变量Path");
                }
                return(false);
            }

#if UNITY_EDITOR_WIN
            string dirPath = string.Format("{0}/Data/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Symbols/armeabi-v7a", unityEditorPath);
            if (Directory.Exists(dirPath))
            {
                string[] soFiles = Directory.GetFiles(dirPath, "*.so", SearchOption.AllDirectories);

                for (int i = 0; i < soFiles.Length; ++i)
                {
                    string fileName = soFiles[i];
                    soFiles[i] = fileName.Replace('\\', '/');
                }

                soFileNameList.AddRange(soFiles);
            }

            dirPath = string.Format("{0}/Data/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Symbols/x86", unityEditorPath);
            if (Directory.Exists(dirPath))
            {
                string[] soFiles = Directory.GetFiles(dirPath, "*.so", SearchOption.AllDirectories);

                for (int i = 0; i < soFiles.Length; ++i)
                {
                    string fileName = soFiles[i];
                    soFiles[i] = fileName.Replace('\\', '/');
                }

                soFileNameList.AddRange(soFiles);
            }
#elif UNITY_EDITOR_OSX
            // 暂时不支持
            return(false);
#else
            return(false);
#endif

            return(true);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 回调函数: 所有的AB包都已经加载完毕了。
        /// </summary>
        /// <param name="abName"></param>
        private void LoadAllABComplete(string abName)
        {
            UnityEngine.Object tmpObj = null;

            //提取资源
            tmpObj = AssetBundleMgr.GetInstance().LoadAsset(_ScenesName, _AssetBundleName, _AssetName, false);
            if (tmpObj!=null)
            {
                Instantiate(tmpObj);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// (回调函数) 调用AB包中的资源
        /// </summary>
        /// <param name="abName">没有用到</param>
        private void LoadABAssetComplete(string abName)
        {
            UnityEngine.Object tmpObj = null;

            tmpObj=AssetBundleMgr.GetInstance().LoadAsset(_ScenesName, _AssetBundleName, _AssetName, false);
            if (tmpObj!=null)
            {
                _CloneUIPrefab = Instantiate(tmpObj);
            }
            _IsLoadFinish = true;
        }
Ejemplo n.º 16
0
 public void OnDestroy()
 {
     try
     {
         StageMgr.Dispose();
         UIMgr.Dispose();
         LevelMgr.Dispose();
         AssetBundleMgr.Dispose(IsDisposeAssetBundleInQuit);
         DataMgr.Dispose();
         Commander.Dispose();
     }
     catch {}
 }
Ejemplo n.º 17
0
 public void Awake()
 {
     DataMgr.SetLog(this);
     Commander.SetLog(this);
     UIMgr.SetLog(this);
     //>========================
     Starter.Initialized(this);
     AssetMgr.Initialized(LevelMgr);
     AssetBundleMgr.Initialized(LevelMgr, AssetBundleExtension);
     UIMgr.Initialized(AssetMgr, AssetBundleMgr);
     StageMgr.SetUpdateInterval(StageUpdateInterval);
     DontDestroyOnLoad(gameObject);
     Starter.RegisterOptionObject(gameObject);
     Starter.RegisterOptionByChildren(gameObject);
     Instance = GetComponent <IGameInstance>();
 }
Ejemplo n.º 18
0
        void SaveAssetBundle(string fileName, byte[] bytes, Action saveLocalComplate = null)
        {
            string     path     = AssetBundleMgr.GetApplicationdataPath() + fileName;
            FileInfo   fileInfo = new FileInfo(path);
            FileStream fs       = fileInfo.Create();

            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Close();
            fs.Dispose();

            if (saveLocalComplate != null)
            {
                saveLocalComplate();
            }
        }
Ejemplo n.º 19
0
    public static Object LoadAsset(string assetName)
    {
        UnityEngine.Object tmpObj = null;
        Object             obj    = null;

        tmpObj = (UnityEngine.Object)AssetBundleMgr.GetInstance().LoadAsset(assetName, false);
        if (tmpObj != null)
        {
            obj = Instantiate(tmpObj);
        }
        if (obj != null)
        {
            return(obj);
        }
        return(null);
    }
Ejemplo n.º 20
0
        private void BeginOperation()
        {
            string path       = m_ProvideHandle.ResourceManager.TransformInternalId(m_ProvideHandle.Location);
            string bundleName = Path.GetFileName(path);

            m_bundleOffset = computeBundleOffset(bundleName);
            path           = AssetBundleMgr.GetInstance().TransformAssetBundleLocation(path, bundleName, m_Options.Hash);
            if (File.Exists(path) || !ResourceManagerConfig.IsPathRemote(path))
            {
                //如果文件存在  情况 1、Editor模式下文件存在  2、persistent下的文件存在  3、streaming asset目录下
                m_RequestOperation            = AssetBundle.LoadFromFileAsync(path, m_Options == null ? 0 : m_Options.Crc, (ulong)m_bundleOffset);
                m_RequestOperation.completed += LocalRequestOperationCompleted;
            }
            else if (AssetBundleMgr.GetInstance().IsCached(bundleName, m_Options.Hash))
            {
                //persistent目录下ab是否存在,是否有缓存
                string cachePath = AssetBundleMgr.GetInstance().getCachedAssetBundlePath(bundleName);
                m_RequestOperation            = AssetBundle.LoadFromFileAsync(cachePath, m_Options == null ? 0 : m_Options.Crc, (ulong)m_bundleOffset);
                m_RequestOperation.completed += LocalRequestOperationCompleted;
            }
            else if (ResourceManagerConfig.ShouldPathUseWebRequest(path))
            {
                // 文件真的需要从网络上下载
                var req = CreateWebRequest(path);
                req.disposeDownloadHandlerOnDispose = false;
                m_WebRequestQueueOperation          = WebRequestQueue.QueueRequest(req);
                if (m_WebRequestQueueOperation.IsDone)
                {
                    m_RequestOperation            = m_WebRequestQueueOperation.Result;
                    m_RequestOperation.completed += WebRequestOperationCompleted;
                }
                else
                {
                    m_WebRequestQueueOperation.OnComplete += asyncOp =>
                    {
                        m_RequestOperation            = asyncOp;
                        m_RequestOperation.completed += WebRequestOperationCompleted;
                    };
                }
            }
            else
            {
                m_RequestOperation = null;
                m_ProvideHandle.Complete <AssetBundleEncryptResource>(null, false, new Exception(string.Format("Invalid path in AssetBundleEncryptResource: '{0}'.", path)));
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 调用AB框架ab包
 /// </summary>
 /// <param name="abPara"></param>
 public void LoadAssetBundlePack(ABPara abPara)
 {
     //仅仅是加载相同AB包中的不同资源
     if ((abPara.ScenesName==_ScenesName)  && (abPara.AssetBundleName==_AssetBundleName))
     {
         _AssetName = abPara.AssetName;
         LoadABAssetComplete(""); //这里的参数没有实际作用。
     }
     else {
         //参数赋值
         _ScenesName = abPara.ScenesName;
         _AssetBundleName = abPara.AssetBundleName;
         _AssetName = abPara.AssetName;
         //调用ABFW 主API
         StartCoroutine(AssetBundleMgr.GetInstance().LoadAssetBundlePack(_ScenesName, _AssetBundleName, LoadABAssetComplete));
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="abModel"></param>
 /// <param name="callback"></param>
 static public void  Init(bool abModel)
 {
     #if UNITY_EDITOR
     if (abModel)
     {
         resLoader = new AssetBundleMgr();
         BDebug.Log("资源加载:AssetBundle");
     }
     else
     {
         resLoader = new ResourcesMgr();
         BDebug.Log("资源加载:AssetDataBase editor only");
     }
     #else
     resLoader = new AssetBundleMgr();
     BDebug.Log("资源加载:AssetBundle");
     #endif
 }
Ejemplo n.º 23
0
        public void StartInjectFix()
        {
#if !UNITY_EDITOR
            string assetBundleName = "hotfix_assets_all.bundle";
            if (AssetBundleMgr.GetInstance().IsCached(assetBundleName, "", true))
            {
                var path  = Path.Combine(AssetBundleMgr.PersistentAssetBundleFolder, assetBundleName);
                var ab    = AssetBundle.LoadFromFile(path, 0, (ulong)computeBundleOffset(assetBundleName));
                var texts = ab.LoadAllAssets();
                for (int i = 0; i < texts.Length; i++)
                {
                    var bytes = (texts[i] as TextAsset).bytes;
                    Debug.Log("Start Patch " + texts[i].name);
                    PatchManager.Load(new MemoryStream(bytes));
                }
                ab.Unload(true);
            }
#endif
        }
Ejemplo n.º 24
0
        private void WebRequestOperationCompleted(UnityEngine.AsyncOperation op)
        {
            UnityWebRequestAsyncOperation remoteReq = op as UnityWebRequestAsyncOperation;
            var webReq = remoteReq.webRequest;

            if (string.IsNullOrEmpty(webReq.error))
            {
                //web 返回成功 需要区分是http还是android streaming asset目录
                m_downloadHandler = webReq.downloadHandler;
                string path       = m_ProvideHandle.ResourceManager.TransformInternalId(m_ProvideHandle.Location);
                string bundleName = Path.GetFileName(path);

                AssetBundleMgr.GetInstance().CacheAssetBundle(bundleName, m_Options.Hash, m_downloadHandler.data);
                m_downloadHandler.Dispose();
                m_downloadHandler = null;

                string cachePath = AssetBundleMgr.GetInstance().getCachedAssetBundlePath(bundleName);

                m_RequestOperation            = AssetBundle.LoadFromFileAsync(cachePath, m_Options == null ? 0 : m_Options.Crc, (ulong)m_bundleOffset);
                m_RequestOperation.completed += LocalRequestOperationCompleted;
                //m_ProvideHandle.Complete(this, true, null);
            }
            else
            {
                m_downloadHandler = webReq.downloadHandler;
                m_downloadHandler.Dispose();
                m_downloadHandler = null;
                if (m_Retries++ < m_Options.RetryCount)
                {
                    Debug.LogFormat("Web request {0} failed with error '{1}', retrying ({2}/{3})...", webReq.url, webReq.error, m_Retries, m_Options.RetryCount);
                    BeginOperation();
                }
                else
                {
                    var exception = new Exception(string.Format("RemoteAssetBundleProvider unable to load from url {0}, result='{1}'.", webReq.url, webReq.error));
                    m_ProvideHandle.Complete <AssetBundleEncryptResource>(null, false, exception);
                }
            }
            webReq.Dispose();
        }
Ejemplo n.º 25
0
        public static void Deserialize(string filename, bool isAssetBundle = false)
        {
            TextAsset textAsset = null;

            if (isAssetBundle && AssetBundleMgr.ContainsFile(filename, "bytes"))
            {
                textAsset = AssetBundleMgr.Load(filename, "bytes") as TextAsset;
            }
            else
            {
                textAsset = Resources.Load(filename) as TextAsset;
            }
            BinaryFormatter formatter = new BinaryFormatter();
            MemoryStream    mstream   = new MemoryStream();

            byte[] tmp = new byte[textAsset.bytes.Length];
            CsvHelper.Encode(textAsset.bytes, 0, tmp, 0, tmp.Length, ASCIIEncoding.ASCII.GetBytes("ABCDEFG2"));
            mstream.Write(tmp, 0, tmp.Length);
            mstream.Position = 0;
            Data             = formatter.Deserialize(mstream) as Dictionary <int, HeroRecord>;
            mstream.Close();
        }
        public static void Deserialize(string filename, bool isAssetBundle = false)
        {
            TextAsset textAsset = null;

            if (isAssetBundle && AssetBundleMgr.ContainsFile(filename, "bytes"))
            {
                textAsset = AssetBundleMgr.Load(filename, "bytes") as TextAsset;
            }
            else
            {
                textAsset = Resources.Load(filename) as TextAsset;
            }
            RecordIdValue.Clear();
            IdRecordValue.Clear();
            Init();
            Init2();
            BinaryFormatter formatter = new BinaryFormatter();
            Stream          stream    = new MemoryStream(textAsset.bytes);

            Data = formatter.Deserialize(stream) as Dictionary <int, LocalizationRecord>;
            stream.Close();
        }
Ejemplo n.º 27
0
    /// <summary>
    /// Important: paramName must include extension, for example "tank.prefab"
    /// </summary>
    /// <param name="paramFolder"></param>
    /// <param name="paramName"></param>
    /// <returns></returns>
    public T GetObj <T>(string param) where T : UnityEngine.Object
    {
        int    tempIndex   = param.LastIndexOf("__");
        string paramFolder = param.Substring(0, tempIndex);

        paramFolder = paramFolder.Replace("__", "/");
        string paramName = param.Substring(tempIndex + 1);

#if UNITY_EDITOR
        var temp = "Assets/" + paramFolder + "/" + paramName;
        return(AssetDatabase.LoadAssetAtPath <T>(temp));
#endif
        paramFolder = paramFolder.Replace("/", "");
        paramFolder = paramFolder.ToLower();
        paramName   = paramName.Remove(paramName.LastIndexOf("."));
        paramName   = paramName.ToLower();
        AssetBundle tempAB = AssetBundleMgr.GetAssetBundle(paramFolder);
        if (tempAB != null && tempAB.Contains(paramName))
        {
            return(tempAB.LoadAsset <T>(paramName));
        }
        Debug.LogError("the things you want to load is null");
        return(null);
    }
Ejemplo n.º 28
0
        /// <summary>
        /// 下载根目录AssetBundle文件
        /// </summary>
        /// <returns></returns>
        IEnumerator DownloadAssetBundles()
        {
            using (UnityWebRequest www = UnityWebRequest.Get(AssetBundlePath + MainAssetBundleName))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError)
                {
                    yield break;
                }

                byte[] datas = www.downloadHandler.data;
                SaveAssetBundle(MainAssetBundleName, datas);
                string      localPath       = AssetBundleMgr.GetApplicationdataPath() + MainAssetBundleName;
                AssetBundle mainAssetBundle = AssetBundle.LoadFromFile(localPath);
                if (mainAssetBundle == null)
                {
                    yield break;
                }
                //获取AssetBundleManifest文件
                AssetBundleManifest manifest = mainAssetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

                //获取AssetBundleManifest中的所有AssetBundle的名称信息
                string[] assets = manifest.GetAllAssetBundles();
                for (int i = 0; i < assets.Length; i++)
                {
                    Debug.Log(AssetBundlePath + assets[i]);
                    //开启协程下载所有的
                    StartCoroutine(DownloadAssetBundleAndSave(AssetBundlePath, assets[i], () =>
                    {
                        //下载完成,按照之前的方法,从本地加载AssetBundle并设置。
                        Image_BackGround.overrideSprite = AssetBundleMgr.LoadResource <Sprite>("UI_1003", "uibackground");
                    }));
                }
            }
        }
Ejemplo n.º 29
0
    //测试销毁资源
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log(GetType() + " 释放所有资源");
            AssetBundleMgr.GetInstance().DisAllAsset();
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            Debug.Log(GetType() + " 释放单个资源");
            AssetBundleMgr.GetInstance().DisAssets("cube");
        }


        if (Input.GetKeyDown(KeyCode.W))
        {
            GameObject cube = Utility.LoadAsset("cube") as GameObject;
            cube.transform.localPosition    = new Vector3(1, 1, 1);
            cube.transform.localScale       = new Vector3(1.2f, 12, 0.5f);
            cube.transform.localEulerAngles = new Vector3(1.2f, 12, 0.5f);
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            GameObject cube = Utility.LoadAsset("sphere") as GameObject;
            cube.transform.localPosition    = new Vector3(5, 5, 10);
            cube.transform.localScale       = new Vector3(1.2f, 12, 0.5f);
            cube.transform.localEulerAngles = new Vector3(1.2f, 12, 0.5f);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            GameObject audio = new GameObject("audio");
            audio.AddComponent <AudioSource>().clip = Utility.LoadAsset("slide") as AudioClip;
            audio.GetComponent <AudioSource>().loop = true;
        }
    }
Ejemplo n.º 30
0
        async static ETTask DownloadAllAssetBundle(this UIUpdateView self)
        {
            var downloadTool = self.AddComponent <DownloadComponent>();

            for (int i = 0; i < self.m_needdownloadinfo.Count; i++)
            {
                var url      = string.Format("{0}/{1}", self.m_rescdn_url, self.m_needdownloadinfo[i].name);
                var savePath = AssetBundleMgr.GetInstance().getCachedAssetBundlePath(self.m_needdownloadinfo[i].name) + ".temp";
                downloadTool.AddDownloadUrl(url, savePath);
            }
            self.RefreshProgress(downloadTool).Coroutine();
            var res = await downloadTool.DownloadAll();

            if (!res)
            {
                var btnState = await self.ShowMsgBoxView("Update_Download_Fail", "Update_ReTry",
                                                         self.force_update? "Btn_Exit" : "Btn_Cancel");

                if (btnState == self.BTN_CONFIRM)
                {
                    await self.DownloadAllAssetBundle();
                }
                else if (self.force_update)
                {
                    GameUtility.Quit();
                }
            }
            else
            {
                for (int i = 0; i < self.m_needdownloadinfo.Count; i++)
                {
                    var downinfo = self.m_needdownloadinfo[i];
                    AssetBundleMgr.GetInstance().CacheAssetBundle(downinfo.name, downinfo.hash);
                }
            }
        }