Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Performance : UI Image versus Sprite ?

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

  1. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    490
    Hi,

    What is the difference between them ?

    Thanks a lot.

    Best regards,

    AB
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,567
    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.
     
  3. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    490
    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,567
    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:
    490
    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:
    17
    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:
    490
    Hi,

    tahnks for your answer.

    To do something like that :

     
  8. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,567
    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.
     
    ababab5 likes this.
  9. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    490
    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,567
    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.
     
    Kasey Wells likes this.