Projets
Voir sur GitHub
aniketrajnish/Unity-Collider-Optimizer
À propos
Optimise les colliders de maillage et de polygones dans Unity.
Jeux et émulationProgression mesurée des étoiles
- in 24h
- -1
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalUnity Collider Optimizer
This package is meant for:
MeshCollideroptimization (3D) via bundled gltfpack binariesOriginal Mesh Unity Mesh Collider Optimized Mesh Collider Tris, Verts Count 3032 tris, 2512 verts 918 tris, 592 verts PolygonCollider2Doptimization (2D) using RDP line simplificationOriginal Sprite Unity Polygon Collider Optimized Polygon Collider Path Count 214 paths 23 paths
Requirements
- Unity 2020.2 or newer recommended
(for
MeshColliderCookingOptions) - A glTF/GLB importer package in your project:
com.unity.cloud.gltfast(glTFast) orcom.unity.formats.glTF(UnityGLTF)
- Supported OS for the included gltfpack binaries:
- Windows
- macOS (Intel & Apple Silicon)
- Linux
[!NOTE] If you don’t have a GLB importer, the tool can’t re-import the simplified mesh and will log an error telling you to install one
Usage
Install
- Download the
collider-opt-pkg-v005.unitypackagepackage from the Releases section and import in your Unity project - Follow the prompt to install the glTF/GLB importer
- (macOS/Linux) If the
gltfpackbinary isn’t executable, the tool will attempt tochmod +xautomatically
Optimize Colliders
- Select a GameObject with a
MeshCollider(3D) orPolygonCollider2D(2D) - Open context menu by right clicking the component header ->
Optimize Collider - If needed you have option to Load/Save/Reset Collider aswell
Adjust Params
- To adjust params for the optimizer go to
Tools -> Collider Optimizer - Mesh Optimization Params:
Contraction: higher contraction -> fewer triangles keptRecalc Normals: recalculate normals after importConvex: setsMeshCollider.convex = true(Unity may auto-reduce to ≤255 tris)Aggressive (-sa): simplifies aggressively (more tris reduced)Permissive (-sp): simplifies permissively (less tris reduced)
- Polygon Optimization Params:
Tolerance: maximum perpendicular distance new path is allowed to deviate from the original path (higher tolerance -> fewer lines kept)Tolerance Mode:World: interpreted in world unitsRelative: interpreted as fraction of per-path bbox diagonal
Scale By Bounds: InWorldmode, multiply tolerance by each path’s bounds diagonal (useful for differently sized shapes)
Presets
- You get the option to define presets for different param sets you'd like to save
- Create presets via
Assets -> Create -> ColliderOptimizer -> Mesh Preset or Poly Preset - In
Tools -> Collider Optimizerwindow assign these presets to make them active - Without an active preset the settings are stored in
Project SettingsatProjectSettings/ColliderOptimizerSettings.asset Reset to Defaultswill update the preset (if assigned) or the project settings to the default values
https://github.com/user-attachments/assets/9530f417-eb80-4108-ab7c-36454a7a409c
Performance Comparison
Gotchas
- For skinned meshes, the tool bakes a static combined mesh for collider usage (as intended for physics), not skinning, anyways I won't use a
MeshColliderfor a skinned mesh - Extremely degenerate or non-triangular topologies are skipped
glb import produced no loadable assets
Install/reinstall a GLB importer package (UnityGLTF or glTFast) & reoptimize- Unity limits convex colliders to ≤255 tris, it may auto-simplify further
- If you see warnings about very large triangles (>500 units), check your model scale. The tool bakes transforms, but mismatched import scales can still yield oversized geometry
- The tool attempts to
chmod +xthegltfpackbinary, if gatekeeper still blocks it, allow it in System Settings or remove quarantine attributes manually
Contribution
Contributions to the project are welcome, consider making a PR
License
MIT License
Explorer des projets similaires
Chargement…