I'm writing an Editor script that takes assets from a directory path, and builds them into an asset bundle.
I want to use: BuildPipeline.BuildAssetBundle(Object main, Object  assets, string outputPath, ...);
That means I need an array of Object. But how do I get the array of Object, given an asset path that contains all the fbx that I need in bundled?
Object objects = AssetDatabase.LoadAllAssetsAtPath("Assets/Art")
interesting idea. I will favorite this one.
Answer by ckfinite
Nov 30, 2010 at 03:35 AM
Why does AssetDatabase.LoadAllAssetsAtPath not work for you? The problem you are havaing with it should be a non-issue. In unity, a asset does not come in as a GameObject. It comes in as the most appropriate class, so a FBX should come in as a Mesh. What I would reccomend doing is instead of checking for a GameObject, print the class name. Try
foreach (object o in objects) Debug.Log(object.GetType().ToString());
which should give you the class names of all the imported objects.
Is your output asset bundle working? I find that is the really important question.
Inside that foreach loop you can do things like "if (o is Mesh)" to find the objects of the type(s) you're interested in.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
How to import the object from server to unity
Set animation clip humanoid
When looping through assetbundle assetdatabase how do you reference a material object
AssetDatabase.CreateAsset randomly fails claiming object has been destroyed