コード例 #1
0
    private void OnAnimationResLoaded(string aniName)
    {
        if (!mAniDatas.ContainsKey(aniName))
        {
            return;
        }
        List <SpriteAniParam> lst = mAniDatas[aniName];

        for (int i = 0; i < lst.Count; ++i)
        {
            SpriteAniParam param = lst[i];

            GameObject go = param.obj;

            UISprite gold = go.GetComponent <UISprite>();
            gold.atlas = UIAtlasHelper.LoadAtlas(aniName);
            gold.MakePixelPerfect();

            UISpriteAnimation spriteAni = go.GetComponent <UISpriteAnimation>();
            if (spriteAni == null)
            {
                GameDebug.LogError("怎么可能出错了");
                return;
            }

            spriteAni.framesPerSecond = param.fps;
            spriteAni.loop            = param.isLoop;
            if (param.isSelfDestroy)
            {
                spriteAni.onFinished += DestroyObj;
            }

            spriteAni.RebuildSpriteList();
            spriteAni.Reset();
            go.SetActive(true);
        }

        mAniDatas.Remove(aniName);
    }