Пример #1
0
    /// <summary>
    /// 直接从缓存中读取,如果没有预加载,则返回空对象并报错
    /// </summary>
    /// <param name="atlas"></param>
    /// <param name="sprite"></param>
    /// <returns></returns>
    public static Sprite LoadSprite(string atlas, string sprite)
    {
        var path = atlas.ToLower();
        var item = LoadResources.GetResourceItem(path);

        if (item != null)
        {
            item.SetType(EResType.Atlas);
            //if (LoadResources.m_loadMode == ELoadMode.Resources)
            //{
            //    if (item.Assets == null)
            //        item.SetAssets((item.MainAsset as GameObject).GetComponent<SpritesHolder>().Sprites);
            //    return item.Load(sprite, typeof(Sprite)) as Sprite;
            //}
            //else if (LoadResources.m_loadMode == ELoadMode.AssetBundle)
            return(item.Load(sprite, typeof(Sprite)) as Sprite);
        }
        Debug.LogError("【Atlas】缓存中不存在该资源:\n" + "atlas:" + path + " sprite:" + sprite);
        return(null);
    }