Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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:
    483
    Hi,

    What is the difference between them ?

    Thanks a lot.

    Best regards,

    AB
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,535
    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:
    483
    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,535
    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:
    483
    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:
    483
    Hi,

    tahnks for your answer.

    To do something like that :

     
  8. SimonDarksideJ

    SimonDarksideJ

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