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 /
avatar image
2
Question by Azound · Sep 07, 2011 at 06:42 AM · editorassetdatabase

How do I get the full path to an asset?

AssetDatabase.GetAssetPath returns me a path relative to the project directory. Application.dataPath returns me the absolute path to the data directory (usually inside the project).

I can't find the path of the project directory anywhere, though. I want to use it in conjunction with the asset path to have a full path. Anyone know how to get that?

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 Rustam-Ganeyev · Sep 07, 2011 at 06:48 AM 0
Share

Application.dataPath returns absolute path relative to building platform, it's different in iphone or android. Where is your asset located?

2 Replies

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

Answer by Waz · Sep 07, 2011 at 01:13 PM

Are you sure you want the full path? The Current Work Directory is set to the project directory, so you certainly can use a relative path when passing paths to system functions, etc.

Comment
Add comment · Show 2 · 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 Azound · Sep 07, 2011 at 05:03 PM 1
Share

Of course! I didn't realize the CWD was already set to the project path. It felt dirty to use the datapath and strip off the "assets" portion. Unity really should provide the project path explicitly rather than just setting it as the CWD.

Thanks, Warwick!

avatar image Waz · Sep 08, 2011 at 05:01 AM 0
Share

I guess the theory is to discourage us from storing absolute paths anywhere, thereby ensuring the project can be freely moved around the file system.

avatar image
2

Answer by jonas-echterhoff · Sep 07, 2011 at 07:29 AM

Application.dataPath should work if you strip the "/Assets" part of it. See the reference: It returns <path to project folder>/Assets when called in the editor.

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 Rustam-Ganeyev · Sep 07, 2011 at 07:37 AM 0
Share

you're right if you're working just in editor.of course, you can hardcode other options too, but it's not the way. And another question is how you will put your asset into application folder(it has just read-access)? As i know, we can just write to Application.persistentDataPath, can't we?

avatar image jonas-echterhoff ♦♦ · Sep 07, 2011 at 07:46 AM 2
Share

"you're right if you're working just in editor." -- But AssetDatabase and the notion of an asset path only exists in the editor. And what do you mean by "just has read-access"? Of course you can write to the Assets directory.

avatar image Rustam-Ganeyev · Sep 07, 2011 at 08:01 AM 0
Share

ough, i didn't noticed assetdatabase. sorry about that.

I was thinking about following situation: we need to store some data(for example that comes from WWW), and we save it into persistentdatapath(because we don't have any other read-write-access folder). And we need to import some data in the build(let's say precache them:) ) using PostprocessBuildPlayer. But we don't know persistentDataPath in PostprocessBuildPlayer script . How to deal this?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Settting Selection.activeObject to multiple items 1 Answer

Proper way to update AssetDatabase after creating assets? 0 Answers

Adding more image to detect but not updating application Arkit. 0 Answers

Creating a Mesh asset inside the editor 1 Answer

inconsistent TextureImporter settings 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