Unity-Technologies / com.unity.uiwidgets

UIWidgets is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
https://unity.cn/uiwidgets
626 stars 78 forks source link

使用RotationTransition旋转的问题 #306

Closed tomcatter closed 2 years ago

tomcatter commented 2 years ago

初始如图: 0222220110 动画执行结束后: 0222220122

原始位置的图还存在,

代码如下:

   AnimationController _animationController;
   Animation<float> _rotateAnimation;
...
    _animationController = new AnimationController(vsync: this, duration: TimeSpan.FromMilliseconds(200));
  _rotateAnimation = new FloatTween(begin: 0.0f, end: 0.5f).animate(new CurvedAnimation(parent: _animationController, curve: Curves.easeInOut));

...

 new RotationTransition(
       turns: _rotateAnimation,
       child: new Icon(Icons.arrow_drop_down, color: Colors.white, size: 100)
  ),
zhuxingwei commented 2 years ago

Hi Thanks a lot for the issue report!

We will look into this as soon as possible and let you know when it is fixed

zhuxingwei commented 2 years ago

Hi, we have tested this flutter sample using the following corresponding C# code snippet but cannot reproduce this bug.

public class ImageTest : UIWidgetsPanel
    {
        protected override void main()
        {
            ui_.runApp(new MyApp());
        }

        protected override void onEnable()
        {
            AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
        }

        class MyApp : StatelessWidget
        {
            public override Widget build(BuildContext context)
            {
                return new WidgetsApp(
                    color: Colors.blue,
                    home: new MyStatefulWidget(),
                    pageRouteBuilder: (settings, builder) =>
                        new PageRouteBuilder(
                            settings: settings,
                            pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
                        )
                );
            }
        }

        class MyStatefulWidget : StatefulWidget
        {
            public override State createState()
            {
                return new _MyStatefulWidgetState();
            }
        }

        class _MyStatefulWidgetState : TickerProviderStateMixin<MyStatefulWidget>
        {
            private AnimationController _controller;
            private Animation<float> _animation;

            public override void initState()
            {
                base.initState();
                _controller = new AnimationController(
                    duration: new TimeSpan(0, 0, 0, 2),
                    vsync: this
                );
                _controller.repeat(reverse: true);

                _animation = new CurvedAnimation(
                    parent: _controller,
                    curve: Curves.elasticOut
                );
            }

            public override void dispose()
            {
                _controller.dispose();
                base.dispose();
            }

            public override Widget build(BuildContext context)
            {
                return new Scaffold(
                    body: new Center(
                        child: new RotationTransition(
                            turns: _animation,
                            child: new Padding(
                                padding: EdgeInsets.all(8.0f),
                                child: new Icon(Icons.arrow_drop_down, color: Colors.blue, size: 100)
                            )
                        )
                    )
                );
            }
        }
    }

Could you please give us a complete sample which can reproduce the bug so that we can investigate further? Thanks !

tomcatter commented 2 years ago

我关闭了Unity Editor后重新打开项目,同样的代码也没有出现这个问题了