Converting editor script to runtime

Hey guys,

So this is kinda an advanced question.
There is this awesome editor script from the UCLA Game Lab that converts transparent images to mesh.

http://games.ucla.edu/resource/unity-mesh-creator/
https://github.com/uclagamelab/MeshCreator

I’m working on converting this code from a editor script, to something that can be done at runtime.
I’ve been reading through the code over the past day and have a pretty good understanding of what is going on.

However, the MeshCreatorData type is evading me because its not defined anywhere and is only exposed through an editor class (it is dynamically created then attached as a component of a gameobject)

Then the MeshCreatorData is shown in the sidebar by MeshCreatorInspector.cs, which is an editor class.

[CustomEditor(typeof(MeshCreatorData))]
public class MeshCreatorInspector :  Editor {

Anyone have any general recommendations that could point me in the right direction?

Of course if I can get this done. I will share it.

It’s part of the project, not Unity. In one of the screenshots I see Scripts/MeshCreatorData.cs.

–Eric

Eric, thanks for pointing that out.

It seems the current version is much different than the one pictured on the site. The screenshots of the early version show it as very straightforward but the new process has been “wizardified”, and there is no longer a MeshCreatorData.cs.

Good catch noticing that though, because the github repo has older versions so I’m gonna look there and it should have a more direct implementation.

For anyone else trying this, it turns out it wasn’t that bad.

Download and older version (version 5 made more sense to me)
MeshCreatorInspector.cs has all the goods in it, the problem is that its an Editor class and everything happens when you hit the Update button. (which isn’ t a thing at runtime)

So first move all the scripts from the Editor folder to the Standard Assets folder
Change MeshCreatorInspector.cs to a MonoBehavior class instead of Editor, and delete any references to editor classes http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.Editor_Classes.html

Then just create a a way to trigger the UpdateMesh() function. Putting it in a Start() function works fine. The whole script is pretty impressive, it has very good performance and runs on mobile.

If you want some of the newer features you can browse the Giuthb commit log and pull the pieces that you need. I recommend the MergeClosePoints for mesh smoothing.

Sorry for the thread resurrection @dchen05 , but I’m trying exactly what you did but I’m having no luck. The plugin does exactly what I need but I need runtime support because bitmaps can be loaded from the network. Can you share your finished script?