Skip to content

Latest commit

 

History

264 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity-SpriteAssist

openupm

ℹ️About

Unity-SpriteAssist is an Unity extension that assist Sprite's mesh creation more conveniently.

🖥️System Requirements

Unity 2021.3 LTS or later versions

📝Features

  • Control Vertex Easily with a Sliderbar.
  • Make a transparent, opaque, complex(transparent + opaque) mesh
  • Convert Sprite to MeshRenderer Prefab

📷Screenshots

image image

📦Installation

Unity Package Manager

You can add https://github.com/sr4dev/Unity-SpriteAssist.git?path=Assets/SpriteAssist to Package Manager. image

OpenUPM

https://openupm.com/packages/com.sr4dev.unity-spriteassist/

openupm add com.sr4dev.unity-spriteassist

Manual installation

Clone or download this repository and copy Assets/SpriteAssist folder to your Unity project.

✏️How to use

  • Select a Sprite asset in the Project window.
  • Select a Mode and adjust parameters.

Mode

image

  • Transparent Mesh: Default Mode. Allow alpha pixel.
  • Opaque Mesh: Disallow alpha pixel. You can use the mesh for opaque shader.
  • Complex: Separate area by alpha.
    • Alpha pixel is converted to Transparent Mesh area.
    • Non-alpha pixel is converted to Opaque Mesh area.
    • To Use Complex mode must be created Mesh Prefab.
    • Complex mode dose not override original Sprite mesh.

Parameter

image

  • Detail: Density and accuracy of the mesh to the Sprite outline.
  • Alpha Tolerance: Threshold for transparency considered when generating the outline.
  • Detect Holes: Detect holes from outline.
  • Edge Smoothing: Smoothing sharp edges.
  • Non-zero Winding: Use Non-zero winding rule. Default Winding rule is even-odd.

Even-odd(left), Non-zero(right)

image

Wikipedia: Non-zero winding

Mesh Prefab

image

  • Prefab: Linked Prefab with Sprite.
  • Create/Remove: Create or remove a Prefab.
  • Default Transparent Shader
  • Default Opaque Shader

Since v1.5.0, the Mesh of a Mesh Prefab is generated as a sub-asset of the sprite texture during texture import, and the prefab's MeshFilter simply references it. The prefab file itself is never rewritten by import, so mesh updates are tracked by Unity's import pipeline (safe against editor crashes, cached by Unity Accelerator, and compatible with Parallel Import).

The Layer, Tag, Sorting Layer/Order, shader and Material of a Mesh Prefab are initial values applied only when the prefab is created. Reimporting the texture, pressing Apply, or running the migration keeps whatever you have changed on the prefab afterwards (including a replaced shader or an external Material), and only relinks the Mesh.

Mesh Prefabs created with older versions embed the Mesh inside the prefab. They keep working but no longer receive automatic mesh updates until migrated. Migrate them from the Project window context menu: SpriteAssist > Migrate Legacy Mesh Prefabs (Selected) handles the selected prefabs, textures and folders (including subfolders), and Migrate Legacy Mesh Prefabs (Entire Project) scans everything under Assets. Only Mesh Prefabs already linked to their source texture are migrated; orphan prefabs are skipped. Individual sprites can also be migrated with Apply (or Migrate Mesh Prefab) in the Sprite inspector.

Triangulation Library

Since v1.3.0, SpriteAssist supports iShapeTriangulation as an alternative triangulation library. You can select the default library in Project Settings.

LibTessDotNet is the stable and lightweight default option. iShapeTriangulation can generate meshes with the same vertex count but fewer thin, elongated triangles, though it is heavier and may fall back to LibTessDotNet automatically when triangulation fails.

By default, the selected triangulation library also applies to Unity Default modes. Disable Apply To Unity Default in Project Settings if you want Unity Default modes to keep Unity's native sprite geometry. Existing sprites need a manual reimport (or Reimport All) after changing this option.

LibTessDotNet

iShapeTriangulation

⚠️Caution!

AssetImporter.userData

This extension uses AssetImporter.userData of Texture asset. If your project already uses userData, it will be overridden.

Unity Document: AssetImporter.userData

Known Issues

  • Does not support SpriteAtlas.
  • Does not support PSD file.

For other issues, please refer to the link. https://github.com/sr4dev/Unity-SpriteAssist/issues

🗺️Roadmap

  • Support pre-packed Sprite.
  • Support Sprite Mode: Multiple.
  • Add Sprite Animation example.
  • Add tutorial(pdf, movies...).
  • Release to the Asset Store.

🔣License

MIT License

📚Library

☕Donation

ko-fi.com/sr4dev

About

Unity Sprite mesh extension

Topics

Resources

Stars

274 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages