public Sprite GetSprite(uint bundle, string path, string suffix) { if (string.IsNullOrEmpty(path)) { return(null); } try { Sprite sprite = null; for (int i = 0; i < spriteList.Count; i++) { if (spriteList[i].path == path && spriteList[i].bundle == bundle) { sprite = spriteList[i].image; break; } } if (sprite == null) { if (bundle > 0) { sprite = LoadResource <Sprite>(bundle, path, suffix); } else { sprite = LoadResource <Sprite>(path, suffix, BundleType.Sprite); } if (sprite == null) { ZLog.Log("sprite is null!!! path = " + path); return(null); } PoolImageInfo <Sprite> info = new PoolImageInfo <Sprite>(); info.path = path; info.image = sprite; info.bundle = bundle; spriteList.Add(info); } return(sprite); } catch (Exception e) { Debug.LogException(e); return(null); } }
public Texture2D GetTexture2D(uint bundle, string path, string suffix) { if (string.IsNullOrEmpty(path)) { return(null); } try { Texture2D texture = null; for (int i = 0; i < spriteList.Count; i++) { if (spriteList[i].path == path && spriteList[i].bundle == bundle) { texture = textureList[i].image; break; } } if (texture == null) { if (bundle > 0) { texture = LoadResource <Texture2D>(bundle, path, suffix); } else { texture = LoadResource <Texture2D>(path, suffix, BundleType.Texture2D); } if (texture == null) { ZLog.Log("Texture is null!!! path = " + path); return(null); } PoolImageInfo <Texture2D> info = new PoolImageInfo <Texture2D>(); info.path = path; info.image = texture; info.bundle = bundle; textureList.Add(info); } return(texture); } catch (Exception e) { Debug.LogException(e); return(null); } }