public void AddAsyncLoadedImage(Image image, string prefabPath, bool needCached, bool unloadBelongedAssetBundleAfterLoaded, bool isShowSpecMatrial = false) { if (m_asyncLoadedImages == null) { m_asyncLoadedImages = new List <AsyncLoadedImage>(); } if (m_loadedSpriteDictionary == null) { m_loadedSpriteDictionary = new Dictionary <string, GameObject>(); } for (int i = 0; i < m_asyncLoadedImages.Count; i++) { if (m_asyncLoadedImages[i].image == image) { m_asyncLoadedImages[i].prefabPath = prefabPath; return; } } UIFormScript.AsyncLoadedImage item = new UIFormScript.AsyncLoadedImage(image, prefabPath, needCached, unloadBelongedAssetBundleAfterLoaded, isShowSpecMatrial); m_asyncLoadedImages.Add(item); }
private void UpdateAsyncLoadedImage() { if (m_asyncLoadedImages == null) { return; } bool flag = false; int i = 0; while (i < m_asyncLoadedImages.Count) { UIFormScript.AsyncLoadedImage asyncLoadedImage = m_asyncLoadedImages[i]; Image image = asyncLoadedImage.image; if (image != null) { GameObject go = null; string prefabPath = asyncLoadedImage.prefabPath; if (!m_loadedSpriteDictionary.TryGetValue(prefabPath, out go) && !flag) { go = UIUtility.GetSpritePrefeb(prefabPath, asyncLoadedImage.needCached, asyncLoadedImage.unloadBelongedAssetBundleAfterLoaded); m_loadedSpriteDictionary.Add(prefabPath, gameObject); flag = true; } if (go != null) { image.color = new Color(image.color.r, image.color.g, image.color.b, 1f); image.SetSprite(go, asyncLoadedImage.isShowSpecMatrial); m_asyncLoadedImages.RemoveAt(i); } else { i++; } } else { m_asyncLoadedImages.RemoveAt(i); } } }