コード例 #1
0
    public void startAnimation(Image _image, string path, FrameAnimationUtil.FrameAnimationSpeed _speed, bool _isLoop = true, AnimationEnd _animationEnd = null)
    {
        if (getFrameData(_image) != null)
        {
            stopAnimation(_image);
        }

        FrameData data = new FrameData(_image, path, _speed, _isLoop, _animationEnd);

        frameDataList.Add(data);
    }
コード例 #2
0
    public FrameData(Image _image, string _path, FrameAnimationUtil.FrameAnimationSpeed _speed, bool _isLoop = true, AnimationEnd _animationEnd = null)
    {
        image        = _image;
        path         = _path;
        speed        = _speed;
        isLoop       = _isLoop;
        animationEnd = _animationEnd;

        for (int i = 1; i < 100; i++)
        {
            Sprite sprite = Resources.Load(path + i, typeof(Sprite)) as Sprite;
            if (sprite != null)
            {
                sprites.Add(sprite);
            }
            else
            {
                break;
            }
        }

        if (sprites.Count == 0)
        {
            Debug.LogError("FrameData 动画路径不存在:" + path);
        }
        else
        {
            if (image)
            {
                image.sprite = sprites[curIndex];
            }
            else
            {
                Debug.LogError("FrameData image为空  " + path);
            }
        }
    }