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
0
Question by user-10703 (google) · Mar 25, 2011 at 05:44 AM · assetsruntimeloading

Place assets onto scene

I just started using Unity and read/watched a lot of tutorials. My basic (probably elementary but I couldn't find a solution after some searching) problem is that I have a bunch of models (.FBX files) and I have them imported in Unity. I could drag and drop them onto the scene and they work fine. But I am trying to write a script (which I attached to an empty gameobject to run it) that reads the names of these assets from a text file and tries to load and place them onto the scene at run time. The problem is not with reading or getting the names from the text file, they work fine.

The FBX files are inside a Resources folder so that I can use Resources.Load(nameOfTheObjectAsString). After much tinkering it is complaining that there is no Renderer attached. Do I have to somehow load the FBX file as a GameObject for it to have a Renderer attached to it? Can Resources.Load() return the asset as a GameObject? My understanding is that Instantiate doesn't work unless the asset is in the scene. Would appreciate it if someone could tell me how to just place the FBX file on the scene at runtime from my script.

Thanks very much in advance and apologies if I have broken any rules.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Mar 25, 2011 at 06:13 AM

Make prefabs, and instantiate them.

My understanding is that Instantiate doesn't work unless the asset is in the scene.

That's incorrect. The point of Instantiate is to put something in the scene that didn't exist before.

Comment
Add comment · Show 3 · 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 user-10703 (google) · Mar 25, 2011 at 06:32 AM 0
Share

Thank you. I'll try this and get back for a reply in case other people have the same issue. A clarification: Looking at the tutorial for making prefabs, it seems that I have to do them manually through the GUI. I have a lot of models. Is there a way to automate the prefab making process? $$anonymous$$aybe a script?

avatar image Eric5h5 · Mar 25, 2011 at 08:09 AM 0
Share

Probably it is possible with editor scripting, yes, although it's not something I've done.

avatar image user-10703 (google) · Mar 25, 2011 at 10:32 PM 0
Share

Ok, I did the Prefab making. However, it gave me the same error (no Renderer attached). I then attached a $$anonymous$$esh Renderer to the prefab and it worked. I then removed that and tried to add it from code and it still worked. Then I removed the prefab and simply added it to my Resources.Load() -ed asset and it still worked. Any reason I shouldn't do it the last way? I understand that packaging all my models inside a Resources folder will blow up my application size. I am looking into Asset Bundles.

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

1 Person is following this question.

avatar image

Related Questions

_Assets store will not load 0 Answers

Instancing ScriptableObject at Runtime, loading and saving via JsonUtility 1 Answer

Can I set an Asset as Addressable at Runtime? 0 Answers

reimporting at runtime? 0 Answers

Do I have to tell unity to load assets only once with cSharp script 4 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