// void IconUpdate() { m_loadNumber = 0; while (m_cellCache.Count > 0) { LoadTextureCell loadTextureCell = m_cellCache[0]; m_cellCache.RemoveAt(0); if (loadTextureCell.iconTexture == null) { continue; } // bool isNewCreated; SyncSetUITexture(loadTextureCell, out isNewCreated); // if (isNewCreated) { m_loadNumber++; } if (m_loadNumber > m_maxLoadEveryFrame) { break; } } }
private void SyncSetUITexture(LoadTextureCell loadTextureCell, out bool isNewCreated) { isNewCreated = false; if (loadTextureCell.iconTexture != null) { Texture2D texure = Texture2DManager.Instance.CreateTextureAuto(loadTextureCell.iconTexture, loadTextureCell.path, out isNewCreated, loadTextureCell.alpha); if (texure != loadTextureCell.iconTexture.texture) { loadTextureCell.iconTexture.texture = texure; loadTextureCell.iconTexture.SetNativeSize(); } } }
/// <summary> /// 每帧最多进行十次图片加载; /// </summary> /// <param name="ui_texture"></param> /// <param name="path"></param> /// <param name="alpha"></param> public void SetUITexture(RawImage uiTexture, string path, bool alpha) { LoadTextureCell loadTextureCell = new LoadTextureCell(uiTexture, path, alpha); if (m_loadNumber > m_maxLoadEveryFrame) { m_cellCache.Add(loadTextureCell); } else { bool isNewCreated; SyncSetUITexture(loadTextureCell, out isNewCreated); if (isNewCreated) { m_loadNumber++; } } }