These components and shaders allow you to add rounded corners to UI elements!
- In Unity, open the Package Manager window (Window -> Package Manager)
- Press the + button in the upper left corner and select Add package from git URL...
- Paste the following URL: https://github.com/kirevdokimov/Unity-UI-Rounded-Corners.git and click Add
- Open
%projectname%/Packages/manifest.json
- Add the following to the dependencies section:
"com.nobi.roundedcorners": "https://github.com/kirevdokimov/Unity-UI-Rounded-Corners.git"
Get .unitypackage
from releases
- Just attach
ImageWithRoundedCorners
to a gameobject with anImage
- Profit
- Just attach
ImageWithIndependentRoundedCorners
to a gameobject with anImage
- Profit
If you need to add/change the image at runtime, call Validate()
and/or Refresh()
to update the materials.
- Attach
ImageWithRoundedCorners
to a gameobject with anImage
- Сreate a new material
- Pick the
RoundedCorners
shader - Attach the material to the
ImageWithRoundedCorners
and theImage
- Profit
- Attach
ImageWithIndependentRoundedCorners
to a gameobject with anImage
- Сreate a new material
- Pick the
IndependentRoundedCorners
shader - Attach the material to the
ImageWithIndependentRoundedCorners
and theImage
- Profit
Each instance of the script creates a separate material at start-up. If you want to share one material with the same rounding radius between multiple images or have more control over when the materials are created and destroyed, use version 2.
If this project has helped you and you'd like to contribute back, you can always buy me a ☕!