Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

[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,650
    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.