Unity import script

Anything you want to share!
User avatar
AdamB
Site Admin
Posts: 2294
Joined: Wed Apr 16, 2008 10:11 am
Location: Brighton, UK
Contact:

Unity import script

Post by AdamB » Sun Aug 23, 2009 5:29 am

For reference this is the Editor script you should be using to import LightUp generated FBX files into Unity.

The (unzipped) script needs to be in the folder Assets/Editor (create Editor if necessary) and it expects the default lightmap naming stub on "lmap-" which is set in the Capture dialog.

Adam

EDIT: Updated to automatically set lightmap texture format to RGB24 to stop compression artefacts.


EDIT2: Updated to correctly set Unity thumbnail image. (Thanks Yann)


EDIT3: Updated to handle transparent/masked textures correctly.


EDIT4: Updated to use PNG images from LightUp v5.
Attachments
LightUp.zip
(2.35 KiB) Downloaded 570 times
Developer of LightUp http://www.light-up.co.uk

Zante
Posts: 105
Joined: Thu Nov 13, 2008 3:05 pm

Re: Unity import script

Post by Zante » Fri Aug 28, 2009 5:33 pm

Thanks Adam, is it worth making a sticky for these scripts?

I've just finished writing a tutorial, it'd be good to have a static link to forward people to for the script as it's updated. : p

The tutorial can be found here: http://tinyurl.com/mkao6p

Colin
Posts: 78
Joined: Sat Apr 18, 2009 8:53 pm

Re: Unity import script

Post by Colin » Mon Aug 31, 2009 6:53 pm

Can either of you say how you would use the script?

User avatar
AdamB
Site Admin
Posts: 2294
Joined: Wed Apr 16, 2008 10:11 am
Location: Brighton, UK
Contact:

Re: Unity import script

Post by AdamB » Mon Aug 31, 2009 7:06 pm

This Unity Editor script works automatically.

1. Export your model using LightUp in Tourtool mode into the Assets folder of your Unity project
2. Switch to Unity and it will pick up the new file automatically
3. As its imported into Unity this script will automatically assign Unity Lightmapped materials.

There is a short vid here showing the workflow.

Adam
Developer of LightUp http://www.light-up.co.uk

Colin
Posts: 78
Joined: Sat Apr 18, 2009 8:53 pm

Re: Unity import script

Post by Colin » Tue Sep 01, 2009 10:03 pm

Of course, I know how to get things into Unity, so the video didn't help. But noticing the part in your earlier message about making an Editor folder in Assets, and putting the script in there, that helped!

I do get this error though:

Assets/LightUp.js(7,41): BCE0018: The name 'AssetPostprocessor' does not denote a valid type. Did you mean 'UnityScript.Scripting.Pipeline.ActiveScriptEntity' ?


Also, many of my models are not in the same place they were in SketchUp, in Tour Tool mode as well as normal view.

User avatar
AdamB
Site Admin
Posts: 2294
Joined: Wed Apr 16, 2008 10:11 am
Location: Brighton, UK
Contact:

Re: Unity import script

Post by AdamB » Tue Sep 01, 2009 10:07 pm

Colin wrote:Of course, I know how to get things into Unity, so the video didn't help. But noticing the part in your earlier message about making an Editor folder in Assets, and putting the script in there, that helped!

I do get this error though:

Assets/LightUp.js(7,41): BCE0018: The name 'AssetPostprocessor' does not denote a valid type. Did you mean 'UnityScript.Scripting.Pipeline.ActiveScriptEntity' ?

Also, many of my models are not in the same place they were in SketchUp, in Tour Tool mode as well as normal view.
You appear to have LightUp.js in your Assets folder which Unity is trying to import. Thats a bad thing. Put it in the Editor folder you created.

LightUp doesn't alter the coordinates / transforms of SU objects, so not sure why they should move..

Adam
Developer of LightUp http://www.light-up.co.uk

Zante
Posts: 105
Joined: Thu Nov 13, 2008 3:05 pm

Re: Unity import script

Post by Zante » Wed Sep 02, 2009 9:34 am

AdamB wrote:
Colin wrote:Of course, I know how to get things into Unity, so the video didn't help. But noticing the part in your earlier message about making an Editor folder in Assets, and putting the script in there, that helped!

I do get this error though:

Assets/LightUp.js(7,41): BCE0018: The name 'AssetPostprocessor' does not denote a valid type. Did you mean 'UnityScript.Scripting.Pipeline.ActiveScriptEntity' ?

Also, many of my models are not in the same place they were in SketchUp, in Tour Tool mode as well as normal view.
You appear to have LightUp.js in your Assets folder which Unity is trying to import. Thats a bad thing. Put it in the Editor folder you created.

LightUp doesn't alter the coordinates / transforms of SU objects, so not sure why they should move..

Adam
I used to have this problem in earlier versions of lightup. Either that or it was just the way Unity handled the fbx file. Even when I export from 3D Studio max, there are times when Unity does not place the geometry in the exact same place it does in max. I think it's an FBX problem, hard to say.

Colin
Posts: 78
Joined: Sat Apr 18, 2009 8:53 pm

Re: Unity import script

Post by Colin » Thu Sep 03, 2009 4:33 pm

Good catch on the location of the js file! After carefully making the Editor folder, I obviously did a slightly less careful drag of the file...

Reimporting gave much better texture results, but many of the models were still in the wrong place. Strangely, this morning I received an email telling me that v1.6 had been released. The email looked a lot like the one from a month ago, but I downloaded and installed today's v1.6 anyway. That didn't help.

I did find though that the models that were in the wrong place also claimed in Unity to be some other models. That is, large buildings now claimed to be trash cans that had been added to the scene. I'm trying to delete the trash cans from SketchUp....

That didn't help, some things were still there but in the wrong place, and some things no longer showed up at all. I tried doing a purge unused in SketchUp, and a Save As, and that didn't help either.

This isn't a model I can put online, it's work in progress, but Adam, would you want to take a confidential look at the model?

User avatar
AdamB
Site Admin
Posts: 2294
Joined: Wed Apr 16, 2008 10:11 am
Location: Brighton, UK
Contact:

Re: Unity import script

Post by AdamB » Thu Sep 03, 2009 5:41 pm

Colin wrote:Strangely, this morning I received an email telling me that v1.6 had been released. The email looked a lot like the one from a month ago, but I downloaded and installed today's v1.6 anyway. That didn't help.
Off by 1 error in the SQL query.. You were so quick off the mark downloading v1.6 last month you got included twice..:-)
Colin wrote:I did find though that the models that were in the wrong place also claimed in Unity to be some other models. That is, large buildings now claimed to be trash cans that had been added to the scene. I'm trying to delete the trash cans from SketchUp....
It sounds like the Assets folder has got confused in Unity. You may want to snapshot it somewhere and do a real cleanout.
Colin wrote:This isn't a model I can put online, it's work in progress, but Adam, would you want to take a confidential look at the model?
No problem, zip it and send it to help and I'll see if I can spot anything.

Adam
Developer of LightUp http://www.light-up.co.uk

Colin
Posts: 78
Joined: Sat Apr 18, 2009 8:53 pm

Re: Unity import script

Post by Colin » Thu Sep 03, 2009 11:07 pm

I went a bit further, and made a new Unity project. Still get the same issues. I'll send a message to Help.

Post Reply