Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by etong · Nov 20, 2010 at 12:39 AM · assetbundleassetdatabasedatapath

How to load Assets as GameObjects?

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?

Additional Analysis:

  1. I can't use Editor's "Selection" API. Because, I can't control what folder is selected in the Editor window.
  2. This doesn't work: Object[] objects = AssetDatabase.LoadAllAssetsAtPath("Assets/Art") , it doesn't load the assets as GameObjects or Texture2D's if I try to cast the Object afterwards. I checked using C# code: if (objects[i] is GameObject), it will return false for all objects in the array. This API works differently from what I assumed. It takes the file path of an asset (ie: /character.fbx), not a folder path, and outputs all children in the fbx as GameObjects.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BerggreenDK · Nov 20, 2010 at 02:39 AM 1
Share

interesting idea. I will favorite this one.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Dec 03, 2010 at 06:47 PM 0
Share

Inside that foreach loop you can do things like "if (o is $$anonymous$$esh)" to find the objects of the type(s) you're interested in.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

"Object reference not set to an instance of an object" but it is. 2 Answers

How to add and remove installed packages more easily? E.g. Google Admob. Package control in Unity? 0 Answers

WebPlayer dataPath 2 Answers

How to use asset bundle as database instead of PlayerPrefs 0 Answers

I don't know how to use AssetDatabase.GetTextMetaDataPathFromAssetPath() 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges