public Sprite[] GetSpritesByName(string bundlePath, string atlasName) { List <Sprite> arr = new List <Sprite>(); if (LGameConfig.GetInstance().isDebug) { Sprite[] sprites = Resources.LoadAll <Sprite>(bundlePath); foreach (Sprite s in sprites) { if (string.IsNullOrEmpty(atlasName) || s.name.StartsWith(atlasName)) { arr.Add(s); } } } else { string bundleName = LGameConfig.GetABNameWithAtlasPath(bundlePath.Split('.')[0] + ".png"); AssetBundle assetBundle = this.GetBundleByName(bundleName); if (assetBundle) { Sprite[] sprites = assetBundle.LoadAllAssets <Sprite>(); foreach (Sprite s in sprites) { if (string.IsNullOrEmpty(atlasName) || s.name.StartsWith(atlasName)) { arr.Add(s); } } } } return(arr.ToArray()); }
protected LWindowBase loadWindow(string name) { LWindowBase ret = null; if (cacheWindows.ContainsKey(name)) { ret = cacheWindows[name]; } else if (delayDisposeWindows.ContainsKey(name)) { ret = delayDisposeWindows[name]; } else { string abName = LGameConfig.GetABNameWithAtlasPath(name); GameObject res = LLoadBundle.GetInstance().LoadAsset <GameObject>(abName, name); GameObject obj = Instantiate(res); obj.name = name; obj.GetComponent <RectTransform>().sizeDelta = canvas.GetComponent <RectTransform>().rect.size; ret = obj.GetComponent <LWindowBase>(); if (ret) { ret.name = obj.name; } } return(ret); }
static public int GetABNameWithAtlasPath_s(IntPtr l) { try { System.String a1; checkType(l, 1, out a1); var ret = LGameConfig.GetABNameWithAtlasPath(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public Sprite[] GetSpritesByName(string bundlePath, string atlasName) { string key = string.Format("{0}_{1}", bundlePath, atlasName); if (spritesCache.ContainsKey(key)) { return(spritesCache[key]); } else { List <Sprite> arr = new List <Sprite>(); if (LGameConfig.GetInstance().isDebug) { Sprite[] sprites = Resources.LoadAll <Sprite>(bundlePath); int spritesLen = sprites.Length; for (int i = 0; i < spritesLen; i++) { Sprite s = sprites[i]; if (string.IsNullOrEmpty(atlasName) || s.name.StartsWith(atlasName)) { arr.Add(s); } } } else { string bundleName = LGameConfig.GetABNameWithAtlasPath(bundlePath.Split('.')[0] + ".png"); AssetBundle assetBundle = this.GetBundleByName(bundleName); if (assetBundle) { Sprite[] sprites = assetBundle.LoadAllAssets <Sprite>(); int spritesLen = sprites.Length; for (int i = 0; i < spritesLen; i++) { Sprite s = sprites[i]; if (string.IsNullOrEmpty(atlasName) || s.name.StartsWith(atlasName)) { arr.Add(s); } } } } spritesCache.Add(key, arr.ToArray()); return(spritesCache[key]); } }
public Sprite[] GetSpritesByName(string bundlePath, string assetName) { string key = bundlePath; if (spritesCache.ContainsKey(key)) { return(spritesCache[key]); } else { if (LGameConfig.GetInstance().isDebug) { Sprite[] sprites = Resources.LoadAll <Sprite>(bundlePath); spritesCache.Add(key, sprites); } else { string bundleName = LGameConfig.GetABNameWithAtlasPath(bundlePath.Split('.')[0] + ".png"); AssetBundle assetBundle = this.GetBundleByName(bundleName); if (assetBundle) { Sprite[] sprites = assetBundle.LoadAllAssets <Sprite>(); spritesCache.Add(key, sprites); } } List <Sprite> _arr = new List <Sprite>(); Sprite[] _sprites = spritesCache[key]; foreach (Sprite s in _sprites) { if (s.name.StartsWith(assetName)) { _arr.Add(s); } } return(_arr.ToArray()); } }