Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
2
Question by Sellene · Sep 17, 2015 at 11:26 AM · scripting problembuilding

AssetDatabase not working on Build

Hello,

I hope someone can help me with this. I don't have a lot of experience with Unity and I have been using this code to load different models into my scene:

 target = AssetDatabase.LoadAssetAtPath(myPath+"figure_"+number+".obj", GameObject);

But when I am about to build the project the console says:

"Assets/Script/modeloGenerico.js(56,18): BCE0005: Unknown identifier: 'AssetDatabase'."

I need to load the models of a folder depending on different conditions. Is there any code I can use for this?

Thanks everyone!

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

2 Replies

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

Answer by Positive7 · Sep 17, 2015 at 12:30 PM

AssetDatabase is for Editor only. http://docs.unity3d.com/ScriptReference/AssetDatabase.html

Put all your obj to Resources folder and use Resources.Load(); http://docs.unity3d.com/ScriptReference/Resources.Load.html

Comment
Add comment · Show 5 · 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 Sellene · Sep 18, 2015 at 09:52 AM 0
Share

Thank you so much!

I have been substituting everything I needed and it works perfectly!

avatar image Positive7 Sellene · Sep 18, 2015 at 11:05 AM 0
Share

You're very welcome. $$anonymous$$eep up the good work!

avatar image Sellene · Sep 18, 2015 at 11:55 AM 0
Share

Do you also happen to know how to check if a file exists?

I was using System.IO.File.Exists("file01.obj") and I need to change it too. I haven't been able to find another solution yet.

avatar image Positive7 Sellene · Sep 18, 2015 at 12:07 PM 1
Share

System.IO.File.Exists("") should work unless you building for webplayer.

 System.IO.File.Exists(Application.dataPath + "Resources/file01.obj") 

or

 System.IO.File.Exists(Application.dataPath + "Assets/Resources/file01.obj") 


or something like that I'm typing this from mobile and I don't remember. You can check it with Debug.Log if path is right. Debug.Log(Application.dataPath + "Assets");

avatar image ImPHL1 · Jan 04, 2019 at 02:51 PM 0
Share

hi.actually the correct file path is:

   System.IO.File.Exists(Application.dataPath + "/Resources/file01.obj");

you just missed a /. @Positive7

avatar image
0

Answer by Sellene · Sep 18, 2015 at 01:11 PM

I guess might have not been using it correctly. I am eager to try it as soon as I finish with something else. I will let you know when it works. Thanks again!

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

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

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to change a built projects name when running? 1 Answer

After Build Scripts no longer functioning in build or editor 1 Answer

What reason could there be, if a parent object refuses to take the new given position? 0 Answers

switch name.contains 0 Answers

I am having scripting errors before I even type anything in 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