- Home /
Convert Unity 2.x asset bundles to Unity 3.x
Hello! We are currently trying to upgrade some old levels to the current version of Unity 3.0 used by our game...
To do this, we are using the following process:
Import the levels into Unity 2, and save them to scenes Upgrade the project to Unity 3, And finally export the asset bundles back out.
But, the problem comes in at step one...
You see, if we try to import the scene in an editor script.... nothing happens If we run the same import code at runtime however, the world imports just fine -- But because it's runtime, there is no way to save it to project scenes!
So, there you have my dilemma, and that brings me to my question:
How can I save asset bundled scenes (as well as their corresponding assets) permanently to a Unity 2 project? Is this impossible? If it is impossible, is there another way to upgrade my asset bundles?
Answer by Dreamora · Jan 02, 2013 at 08:51 AM
You can not convert asset bundles nor can you even extract all the required data from the bundles as they do not contain all informations (part of the stuff like shaders and scripts are part of the project itself only)
You need to use the original project, convert that one to Unity 3 (and then 4 unless you want to repeat the procedure in 4 months), and then export the asset bundles from there.
Well, our users were the ones who created these worlds, we don't have access to the original projects :( The worlds don't actually use any scripts, and what custom shaders that our users have used have been working fine, even though those were not a part of the original app we produced.
So, with that in $$anonymous$$d, is there any way to import the asset bundles into our original project, and have them actually stay there, not disappear when the play button is un-clicked?
You could see if the following script works in Unity 2 or adopt it to do it, then import the assets, convert to U3 (and then U4 to save future sanity) and reexport it. http://forum.cgpersia.com/f79/unpackassets-editor-unity-3d-51528/
This is all under the assumption that you don't violate your users copyrights by extracting it for such a purpose naturally
Hey, thee, Dreamora! Thanks a ton for the reply :) We checked out that linked and have been trying the code in 2.6.1, however it seems to want to import a library called UnityEditorInternal... Unfortunately, doing that is causign an error:
Assets/Editor/UnpackAssets.cs(4,7): error CS0246: The type or namespace name `UnityEditorInternal' could not be found. Are you missing a using directive or an assembly reference?
We did as the forum post suggests, (paste the code into a C# file named UnpackAssets.cs, and then placed that file into the Editor folder), and Googling has returned no results -- The only thing I can think of is that the script requires Unity 2.0 pro (which we don't have) due to some kind of sandboxing imposed by indie. Do you know anything about these issues?
This answer is a little old, but I'm posting information in related answers of our community, to clarify how Shaders and Asset Bundles work together, and how to avoid some conflicts. The shader's code is included with the asset bundle, whenever shaders are directly referenced as parameters in BuildPipeline.BuildAssetBundle(), or indirectly with option BuildAssetBundleOptions.CollectDependencies. This could cause a problem if you use BuildAssetBundle alone to create several asset bundles, since referenced shaders will be included in every generated bundle. There could be conflicts, i.e. when you mix different versions of a shader, so you will have to rebuild all your bundles for any modification. This also increases the size of bundles. To avoid these problems you can use BuildPipeline.PushAssetDependencies() to separate shaders in a single bundle, and that will allow you to update the shader bundle only. We are adding a page to the manual with more information on this topic and examples of the workflow to build a shader bundle.