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

Clip image

Discussion in 'UI Toolkit' started by Guedez, Oct 3, 2021.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    So I want to make an HP bar where the inner image is a texture rather than a flat image.
    How do I clip this image based on a float? The best I can think is manually setting it's UV and width every frame.
     
  2. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    358
    The UV/width technique would work. Otherwise you could have two elements. The parent element acting as the clipper would have overflow set to hidden and its size would change. A nested element of fixed size could display the full-size texture.
     
    Guedez likes this.
  3. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    the nested element of fixed size needs to adapt to it's grand's parent size, but I guess since I am using code to solve it anyways, might as well.