Mesh Viewer

Author
[mailto:schoen@defectivestudios.com Matt Schoen] of Defective Studios

= Intro = The MeshViewer Editor Window is a simple window for inspecting the insides of Unity meshes. I found the need for it while working on a project heavy with procedural meshes. I wanted to be able to poke at vertex positions, triangle indices, etc. and found that there was no good way to do so already. The script is pretty straightforward. As with any Editor scripts, it must be put in a folder called Editor inside your Assets folder. It adds the menu option: Window -> MeshViewer. To use the window, simply open it up and drop a GameObject into the field on the upper-left that has either a MeshFilter or SkinnedMeshRenderer component. Click any of the toggles on the second row to view the info in the lower pane. As you click more toggles, the different bits will show up next to each other left-to-right, with vertical scrollbars if all the information doesn't fit. There is a const int in the script to limit the number of vertices, etc. shown so that the GUI doesn't slow to a crawl for huge meshes. If you need to see more, increase the number.

= Issues/Future Improvements =
 * The GUI obviously needs some work. The Link Scrollbars function works alright, but doesn't account for different info types that may or may not use more than one line per item, or info types that have mismatched counts.
 * I also considered using GetComponentInChildren instead of GetComponent, but figured that it was better to specify the object itself rather than just choosing the first child.
 * There have been some zombie reference issues that cropped up over the course of working on the script. For one thing, if the script encounters certain errors, it can get permanently stuck in the GUI loop, and refuse to close, etc.  The only solution is to modify the script, for example to put obj = null after it is set in the first GUI block to avoid any null reference errors below.  You'll have to think creatively if you get into trouble here :)

= Code =