Пример #1
0
    public void GetSprite(string atlasName, string spriteName, LuaFunction luaCallback)
    {
        UIAtlas tmpAtlas;

        if (!mAtlasCache.TryGetValue(atlasName, out tmpAtlas) || tmpAtlas == null)
        {
            tmpAtlas = new UIAtlas();
            tmpAtlas.Init(atlasName);
            mAtlasCache[atlasName] = tmpAtlas;
        }
        AppFacade.Instance.GetManager <KResourceManager>().StartCoroutine(
            tmpAtlas.GetSprite(spriteName, (sp) =>
        {
            if (luaCallback != null)
            {
                luaCallback.BeginPCall();
                luaCallback.Push(sp);
                luaCallback.PCall();
                luaCallback.EndPCall();

                luaCallback.Dispose();
                luaCallback = null;
            }
        }));
    }
Пример #2
0
    public Sprite GetSprite(UIAtlasName atlasName, string spriteName)
    {
        UIAtlas a = null;

        if (!dict.TryGetValue(atlasName, out a))
        {
            a = new UIAtlas();
            AssetsList al = LoadAsset(atlasName.ToString());
            a.Init(al);
        }
        if (a != null)
        {
            Sprite s = a.Get(spriteName);
            if (s == null)
            {
                Debug.LogError(string.Format("atlas.Get not find {0} in {1}", spriteName, atlasName));
            }
            return(s);
        }
        Debug.LogError(string.Format("GetSprite not find {0} in {1}", spriteName, atlasName));
        return(null);
    }