x


Intercept file import

Is it possible in Unity to override / add to the default automatic asset import behavior? I would like to add custom behavior to the way that Unity handles Modo lxo files. Ideally I would like to be able to completely take over the import procedure for certain lxo files that the user could specifies.

more ▼

asked May 05 '12 at 01:19 PM

deus_duke gravatar image

deus_duke
18 4 6 8

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You might be able to use AssetPostprocessor.OnPostprocessAllAssets. If it's not a supported asset type it is usually recognised as "TextAsset" so you can access it as binary data. If you want a custom inspector for the asset itself you could try to implement your own editor for TextAsset (so you replace the old TextAssetInspector which is an internal class).

I never tried something like that. I'm also not sure if Unity will treat such assets as TextAssets but if it does it should work.

edit
I'm pretty sure that you can't create your own assettype. Unity can't handle that in their assetdatabase.

more ▼

answered May 05 '12 at 01:30 PM

Bunny83 gravatar image

Bunny83
46.9k 12 50 210

Modo is one of the supported packages, and lxo is an accepted asset type to Unity. I am trying to override the default behavior for these particular types of asset in Unity. I believe what you have given me is enough to accomplish my goal, thanks!

May 06 '12 at 07:37 PM deus_duke

Sorry, I'm not an artist and I've never come across a lox file ;) So it's basically just a model. Unity uses the collada exporter of modo since Unity only supports ".FBX, .dae, .3DS, .dxf and .obj"

Model assets are fully processed by an AssetPostprocessor so you can change anything afterwards.

Keep in mind that Unity doesn't use the asset itself. Model-assets are represented be it's importer. The importer will create sub assets (which are stored in the library folder in the assetdatabase). Those sub assets are usually the mesh data as seperate Mesh, the bone hierarchy as a GameObject tree and animations as anim assets.

You can add your own stuff as sub assets to any kind of asset via AssetDatabase.AddObjectToAsset. But like stated in the docs when you reimport the asset such sub assets will be lost.

May 06 '12 at 08:20 PM Bunny83

Oh so is it not possible to tell Unity not to import anything from the lxo at all? My goal is to mark certain assets to not be imported by Unity but to defer all processing to my script, which will process the file.

May 07 '12 at 02:21 AM deus_duke

No that's not possible. You could rename the file to .txt so it's just a text asset and Unity won't do any processing with it, but you can read the content in an editor script. See TextAsset

May 07 '12 at 03:15 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

Ah that's different then what I had in mind but it works. Thanks for all your help!

more ▼

answered May 07 '12 at 04:35 AM

deus_duke gravatar image

deus_duke
18 4 6 8

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x428
x184
x60
x28
x2

asked: May 05 '12 at 01:19 PM

Seen: 741 times

Last Updated: May 07 '12 at 04:35 AM