After building an AssetBundle with BuildPipeline.BuildAssetBundle, I can find and access assets inside the bundle with AssetBundle.Contains.
After building a StreamedScene with EditorApplication.SaveScene, I can't find or access any of the assets inside of it when loading it's AssetBundle via the WWW class.
Is this expected Unity behavior - and if so, how do I access textures and things inside the StreamedScene?
asked Dec 11 '09 at 08:57 PM
Our API for this is defenitely a bit confusing. If you download this special "scene in an assetbundle", you can access it like this:
You can also find some example code in this example project:
answered May 20 '10 at 11:05 AM
Lucas Meijer 1 ♦♦
A scene file is really just a set of references to asset instances, along with their positions, etc. The assets themselves are not part of the scene. An AssetBundle, on the other hand, does package up the referenced assets so they can be reimported.
answered Jan 13 '10 at 11:31 AM
a saved scene is different from an asset bundle containing a scene. a scene file made with SaveScene is a file containing references to the real asset files but an asset bundle containing a scene really contains all assets in the scene. you should instantiate the main prefab of that scene to load it (instantiate all of it's GameObjects). so you can not get the assets inside a scene file because there is no asset file inside it. you can use GameObject.Find to find all GameObjects and then get their components. it's a slow so be careful. also you can create an asset bundle from your scene if you like. you can create a list and insert a reference of each asset that you want in to it and use the list later. just in Awake or Start to add a reference from current GameObject's Texture or mesh or ... to the list. it's a good idea to have such a list in unity as a built in feature but it's an overhead for those who don't want it. also you can just use a list of GameObjects and then get their components at the time that you need it. you should include
then in a static class create a list
then in Awake of each GameObject do something like
manager is the name of that static class. then you can easily use this list to get Reference to each of your objects. even better you can use a dictionary to have a pair of name and gameObject and then find each gameObject with it's name. it's so fast. it's a hashtable so just one IO is needed. if you are on the iphone, generics are not available but still you can use normal lists in System.Collections. those list just get objects of type System.object and you need casting to add or get object from or to lists.
answered Jan 27 '10 at 02:33 PM