Author Topic: [info] Exporting Prefab  (Read 5711 times)

Fbary

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
[info] Exporting Prefab
« on: April 19, 2012, 03:57:10 AM »
I need to know something about exporting UI package. I'm creating a UI for a project, but i started working on it in another external project. I wanted to develop al the UI structure and then exporting it as a prefab and importing it in my main project. Is it possible without any problems? (like missing scripts, altas etc..)


Waiting forward to answers =)


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [info] Exporting Prefab
« Reply #1 on: April 19, 2012, 11:44:26 AM »
Moving from one project to another project you need to export unity packages, not prefabs. Prefabs only work within the same project.

Fbary

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: [info] Exporting Prefab
« Reply #2 on: April 19, 2012, 03:48:29 PM »
yep, i exported a prefab as package, and tried to reimport it in another project. All the atlas were missing (i had to set them one by one), and there were other resolution and scale problems..

I just tought that would be easier to export a part of a project made with nGUI =P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [info] Exporting Prefab
« Reply #3 on: April 19, 2012, 03:50:21 PM »
You need to export all the dependencies as well or it won't work. NGUI is exported as a package, and you can too. :)

Pangamini

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: [info] Exporting Prefab
« Reply #4 on: October 08, 2013, 03:38:30 AM »
Sure we can export NGUI together with the prefab... but what of other project already contains NGUI? All references are broken again, i have a serious problem transferring complex NGUI object between project now... is there any tool, any way, any help?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [info] Exporting Prefab
« Reply #5 on: October 08, 2013, 12:57:18 PM »
References to scripts will only be broken if you copied the files at any point without their metadata. So if you copy a script from one project to another in Windows Explorer for example, you will break linkage. That's how Unity works. It doesn't go by name. It goes by hidden metadata. This is why exporting a package is important. It keeps the metadata.

Once linkage is broken, nothing will help to restore it. So if you copied NGUI at some point, then created an entire UI... you're pretty much screwed with that project, and you won't be able to update NGUI properly. The only thing you can do is what you did in the first place -- copy the updated NGUI's files into your broken project with Windows Explorer instead of Unity.

Pangamini

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: [info] Exporting Prefab
« Reply #6 on: October 10, 2013, 01:29:48 AM »
Would it work if, instead of copying in the exporer, i imported the same NGUI package in both projects, then exported? Does package itself contain metadata?

BTW, i got a script that restores missing scripts based on their serialized members and it works very well with everything except for most NGUI stuff. Is that because of you serialize things using some custom inspectors? Perhaps... Some script that would serialize prafabs into some JSON, based on script and asset names instead would be very handy

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [info] Exporting Prefab
« Reply #7 on: October 10, 2013, 05:24:48 AM »
Serialization of the UI into a json-like hierarchy is a planned feature.

Package contains metadata, which is why it works, while copying stuff in explorer does not. You can make Unity show the hidden metadata by choosing it in the editor settings.

And no, it won't work. Once metadata is broken, you can't fix it easily. All you can do is repeat the same process you made before where you imported NGUI into a different project, then copied the files from it to your broken project using explorer.