Skip to content

irakli/ui-corner

Repository files navigation

UICorner

GPU-accelerated rounded and chamfered corners for Unity UI elements.

Installation

Via OpenUPM (Recommended)

Install via OpenUPM CLI:

openupm add com.iraklichkuaseli.uicorner

Or add the package via OpenUPM scoped registry in Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "OpenUPM",
      "url": "https://package.openupm.com",
      "scopes": ["com.iraklichkuaseli"]
    }
  ],
  "dependencies": {
    "com.iraklichkuaseli.uicorner": "1.1.1"
  }
}

Via Git URL

Add this line to your Packages/manifest.json:

{
  "dependencies": {
    "com.iraklichkuaseli.uicorner": "https://github.com/irakli/ui-corner.git"
  }
}

Or install via Package Manager:

  1. Open Window → Package Manager
  2. Click the + button
  3. Select "Add package from git URL"
  4. Enter: https://github.com/irakli/ui-corner.git

Requirements

  • Unity 2021.3 or later

Features

  • Dual Corner Styles: Rounded (circular arc) and Chamfered (45-degree diagonal cut)
  • Per-Corner Control: Mix and match styles independently for each corner
  • High Performance: 2.5-3.1× faster than comparable solutions
    • Single quadrant selection (vs calculating all 4 corners)
    • Minimal GPU operations (1 sqrt vs 6+ in alternatives)
    • No trigonometric functions
  • Responsive Inspector: Clean UI that works on narrow inspector windows
  • Production Ready: Automatic size clamping prevents geometry breakdown

Usage

  1. Add UICorner component to any UI Image
  2. Configure each corner independently:
    • Style: Rounded or Chamfered
    • Size: Corner radius (auto-clamped to prevent overlap)

Technical Details

Implementation: Signed Distance Field (SDF) rendering using Inigo Quilez's quadrant-selection technique

Compatibility: Works with Unity UI Mask system and all standard Image features

Integration API

UICorner exposes a PropertiesChanged event that fires whenever corner properties (radius or style) change. This allows you to react to changes for animations, shadow updates, or other visual effects.

var uiCorner = GetComponent<UICorner>();
uiCorner.PropertiesChanged += () => {
    // React to corner property changes
};

Package Structure

com.iraklichkuaseli.uicorner/
├── package.json             # UPM package manifest
├── README.md                # This file
├── CHANGELOG.md             # Version history
├── LICENSE.md               # MIT License
├── Runtime/
│   ├── UICorner.cs          # Main component
│   ├── IrakliChkuaseli.UICorner.asmdef
│   └── Shaders/
│       ├── UICorner.shader  # Main shader
│       └── UICornerSDF.cginc # SDF calculations
├── Editor/
│   ├── UICornerEditor.cs    # Custom inspector
│   └── IrakliChkuaseli.UICorner.Editor.asmdef
├── Icons/
│   └── UICornerIcon.png     # Component icon
└── Tests/
    ├── Editor/              # Editor tests (placeholder)
    └── Runtime/             # Runtime tests (placeholder)

Credits

SDF technique based on Inigo Quilez's 2D distance functions

About

GPU-accelerated rounded and chamfered corners for Unity UI elements

Resources

License

Stars

Watchers

Forks

Packages

No packages published