Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Sprite SetVertexAttribute and bounds problem

Discussion in '2D' started by trapung, Oct 31, 2022.

  1. trapung

    trapung

    Joined:
    Jul 21, 2015
    Posts:
    8
    I used Sprite.SetVertexAttribute for changing vertices, but SpriteRenderer's bounds was not changed.
    Also, it dosen't seem to work ResetBounds() or ResetLocalBounds() for SpriteRenderer..

    Is there anyway to set SpriteRenderer's bounds?
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Did you tried to do the obvious and set bounds (or localBounds) property to set the bounds?

    Documentation for both of them suggest that just assigning a new bounds value should work.

    https://docs.unity3d.com/ScriptReference/Renderer-localBounds.html
    https://docs.unity3d.com/ScriptReference/Renderer-bounds.html
    It also explains that resetBounds is only useful to reset after you have overridden them by assigning custom bounds value. It's useless if you haven't set bounds value before that.
     
  3. trapung

    trapung

    Joined:
    Jul 21, 2015
    Posts:
    8
    Ahhh.. It's my pooor mistake, I misunderstood ResetBounds/LocalBounds()...
    It works. Thanx a lot !