Example #1
0
        IEnumerator DownLoadWndAsset(string wndName, AssetBundleConfig config)
        {
            IEnumerator itor = null;

            SortedDictionary <int, List <DependencyAsset> > prefabData = config.GetConfig(wndName);

            if (prefabData != null)
            {
                foreach (KeyValuePair <int, List <DependencyAsset> > kvp in prefabData)
                {
                    foreach (DependencyAsset dasset in kvp.Value)
                    {
                        if (m_AssetLoaderMap.ContainsKey(dasset.AssetType))
                        {
                            itor = m_AssetLoaderMap[dasset.AssetType].LoadAssetSync(dasset.AssetName, false, true, DownLoadOrderType.AfterRunning, true);
                            while (itor.MoveNext())
                            {
                                yield return(null);
                            }
                            m_AssetLoaderMap[dasset.AssetType].ReleaseAsset(dasset.AssetName, null, true);
                        }
                    }
                }
            }
        }
Example #2
0
 void ReleaseWndAsset(string wndName, AssetBundleConfig config)
 {
     for (AssetBundleType arType = AssetBundleType.Texture; arType < AssetBundleType.Max; ++arType)
     {
         SortedDictionary <int, List <DependencyAsset> > textureData = config.GetConfig(wndName, arType);
         if (textureData != null)
         {
             if (m_AssetLoaderMap.ContainsKey(arType))
             {
                 foreach (List <DependencyAsset> list in textureData.Values)
                 {
                     foreach (DependencyAsset dasset in list)
                     {
                         m_AssetLoaderMap[arType].ReleaseAsset(dasset.AssetName, null, true);
                     }
                 }
             }
         }
     }
 }
Example #3
0
        IEnumerator LoadWndAsset(string wndName, bool bResident, AssetBundleConfig config)
        {
            IEnumerator itor = null;

            SortedDictionary <int, List <DependencyAsset> > prefabData = config.GetConfig(wndName);

            if (prefabData != null)
            {
                foreach (KeyValuePair <int, List <DependencyAsset> > kvp in prefabData)
                {
                    foreach (DependencyAsset dasset in kvp.Value)
                    {
                        if (m_AssetLoaderMap.ContainsKey(dasset.AssetType))
                        {
                            itor = m_AssetLoaderMap[dasset.AssetType].LoadAssetSync(dasset.AssetName, bResident, false, DownLoadOrderType.AfterRunning, true);
                            while (itor.MoveNext())
                            {
                                yield return(null);
                            }

                            //删除美术图集压缩包(临时解决方案)
                            if (CommonValue.PhoneOS == Phone_OS.Ios)
                            {
                                if (dasset.AssetName.Equals(wndName))
                                {
                                    m_AssetLoaderMap[dasset.AssetType].GetMainAsset(dasset.AssetName);
                                    m_AssetLoaderMap[dasset.AssetType].UnloadAssetBundle(dasset.AssetName);
                                }
                                else
                                {
                                    if (dasset.AssetType == AssetBundleType.Pre)
                                    {
                                        GameObject obj       = m_AssetLoaderMap[dasset.AssetType].GetMainAsset(dasset.AssetName) as GameObject;
                                        Material   spriteMat = CommonValue.GetAtlasMatCB(obj);
                                        if (spriteMat != null)
                                        {
                                            string objPartName = dasset.AssetName.Substring(3);

                                            Material mat      = (Material)m_AssetLoaderMap[AssetBundleType.Material].GetMainAsset("m_" + objPartName);
                                            Texture  mainTex  = (Texture)m_AssetLoaderMap[AssetBundleType.Texture].GetMainAsset("t_" + objPartName);
                                            Texture  alphaTex = (Texture)m_AssetLoaderMap[AssetBundleType.Texture].GetMainAsset("t_" + objPartName + "_a");
                                            if (mat != null)
                                            {
                                                if (mainTex != null)
                                                {
                                                    if (alphaTex != null)
                                                    {
                                                        spriteMat = mat;
                                                        spriteMat.SetTexture("_MainTex", mainTex);
                                                        spriteMat.SetTexture("_AlphaTex", alphaTex);

                                                        m_AssetLoaderMap[AssetBundleType.Material].UnloadAssetBundle("m_" + objPartName);
                                                        m_AssetLoaderMap[AssetBundleType.Texture].UnloadAssetBundle("t_" + objPartName);
                                                        m_AssetLoaderMap[AssetBundleType.Texture].UnloadAssetBundle("t_" + objPartName + "_a");
                                                    }
                                                    else
                                                    {
                                                        Debug.LogWarning("==LoadWndAsset==" + objPartName + ",alphaTex" + alphaTex);
                                                    }
                                                }
                                                else
                                                {
                                                    Debug.LogWarning("==LoadWndAsset==" + objPartName + ",mainTex" + mainTex);
                                                }
                                            }
                                            else
                                            {
                                                Debug.LogWarning("==LoadWndAsset==" + objPartName + ",mat" + mat);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }