Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Question]Animation of UICanvas.

Discussion in 'Project Tiny' started by WellC, Dec 27, 2018.

  1. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    I tried using Addtween to move the UI entity but it didnt work.
    This is my code.
    Code (CSharp):
    1.  ut.Tweens.TweenService.addTween(world, panelEntity,
    2.                 ut.Core2D.TransformLocalPosition.position.y,
    3.                 position.y,
    4.                 2.5,
    5.                 .5,
    6.                 0,
    7.                 ut.Core2D.LoopMode.Once,
    8.                 ut.Tweens.TweenFunc.Linear,
    9.                 false);
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    Can you be more specific? "Didn't work" is quite vague.
     
  3. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    Thanks for your reply.

    My UICanvas in other entity group.
    1.I created an entity group(UICanvas entity group)
    2.Find the UI Entity(name is Image)
    3.Addtween animation...
    ---
    But it didnt work.

    upload_2018-12-27_22-56-37.png

    Code (CSharp):
    1.         static once: boolean = false;
    2.  
    3.         OnUpdate(): void {
    4.             if (TestSystem.once) return;
    5.             TestSystem.once = true;
    6.             ut.EntityGroup.instantiate(this.world, "game.UICanvas");
    7.             alert("created");
    8.             this.Animation();
    9.         }
    10.         Animation(): void {
    11.             let entity = this.world.getEntityByName("Image");
    12.             if (!entity.isNone())
    13.                 ut.Tweens.TweenService.addTween(this.world, entity,
    14.                      ut.Core2D.TransformLocalPosition.position.y,
    15.                       1, -1, 1, 0, ut.Core2D.LoopMode.PingPong, ut.Tweens.TweenFunc.Linear, false);
    16.         }
     
  4. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    solved


    We can not using
    ut.Core2D.TransformLocalPosition.position.y
    to moving UI....
    We need using
    ut.UILayout.RectTransform.anchoredPosition
    to moving UI
     
  5. nik_ai

    nik_ai

    Joined:
    Jun 14, 2017
    Posts:
    9
    Hi @WellC
    Can you share working tween example, because i'm confused with implementation of tween, i did not understand how to tween something.
    Thanks.
     
  6. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    OK, It will come soon.