Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Performance : UI Image versus Sprite ?

Discussion in 'UGUI & TextMesh Pro' started by ababab5, Mar 31, 2015.

  1. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    What is the difference between them ?

    Thanks a lot.

    Best regards,

    AB
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
    The main difference is the renderer, Sprites use a SpriteRenderer and UI uses a CanvasRenderer.

    Other than that, not much.

    UI is effectively the 2D sprite system bounded by a heap load of additional functionality to layout your UI for rendering.
     
    John_Mi likes this.
  3. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    Thanks for your reply.

    So it cost much to use an UI Image than a Sprite..

    Thanks a lot !
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
    It depends on what you want to use it for.
    I find if you have fixed UI or static UI, then the new system is brilliant.

    If you just want to draw 2D objects in a scene or use world coordinates for everything, or need physics applied to 2D object, then the 2D system is better.

    As with everything, use that which makes sense.
     
  5. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Perfect thanks.

    Is it possible to add a rigid body to an ui element ? Like a chart pie with a rigidbody who is updated with the chart pie update?

    Thanks again !
     
  6. louisgv

    louisgv

    Joined:
    Aug 7, 2013
    Posts:
    18
    You can attach a rigidbody to any game object in the hierarchy. However, for UI element, unless you use the whole canvas as a the game view, it might be pointless to attach one. What might you be using the rigidbody for though?

    For a pie chart, you need an angle, a center point, a split point, and a radius. What might rigidbody contribute :-?..
     
    Last edited: Apr 3, 2015
  7. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    tahnks for your answer.

    To do something like that :

     
  8. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
    I would be wary about adding physics elements to UI components. They are rendered in a different way to normal GO's

    In all my tests previously, you get a significant about of lag because UI is only processed in the main Update/LateUpdate loop. Changes in FixedUpdate do not apply until the next frame.

    You can add RigidBody and Collision components to UI, it just doesn't update frequently.
     
    KasiAsa and ababab5 like this.
  9. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    Thanks !

    Do you see another solution to do something like the youtube video I sent ?

    Thanks again !

    Best regards,

    AB
     
  10. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
    If it's the gameplay you are referring to, then I would just use the 2D sprite system, not the UI system.

    UI is for UI/UX, the 2D system is for your game/gameplay.

    Looks like a outer circle mesh with a mesh collier and a 2D sprite with a simple box collider. Obviously you could go more complicated that that if you wished.
     
    AmazinJacks, chanfui and KaseyW like this.