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
1
Question by $$anonymous$$ · Oct 24, 2012 at 01:36 PM · resourcespath

Get resource path

Hi,

I use Resources.LoadAll(path) to load all items in the folder and subfolders. After I do this I would like to get the subfolder's name of the objects, or the complete path like I see in the editor. Is this possible?

And don't suggest AssetDatabase, because it is an editor class, and I need it in my build.

Thanks in advance.

Comment
Add comment · Show 7
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 tnetennba · Oct 24, 2012 at 02:10 PM 0
Share

The Application API has useful calls for getting paths for data, persistantData, strea$$anonymous$$g assets etc:

http://docs.unity3d.com/Documentation/ScriptReference/Application.html

Beyond that you could use the System.IO.Directory:

http://msdn.microsoft.com/en-us/library/system.io.directory.aspx

avatar image $$anonymous$$ · Oct 24, 2012 at 02:15 PM 0
Share

The resource loaded is inside the build, it is not yet a file. I want to get the directory like I see in the editor. So the Directory class I cannot use, because you need a real file to get the path. And I cannot find the function I need in the Application class.

avatar image tnetennba · Oct 24, 2012 at 02:38 PM 0
Share

You are right, I forgot it was only one file when built to a standalone. Application.dataPath will give you the path to your Data folder then adding resources.assets will give you the file but beyond that there is no way access the internals of the file. The only way to know the paths etc would be to add a build step that saved them in text/xml and you could reference back to that.

avatar image $$anonymous$$ · Oct 24, 2012 at 03:08 PM 0
Share

So no other way? I cannot create a build step, because this will not get deployed on an iOS device. Or will it?

avatar image tnetennba · Oct 24, 2012 at 03:10 PM 0
Share

This is going to sound odd but if you create a custom menu entry to build your project and in that function parse the resources directory of your project. Then put this in a text file and add it to your resources directory. This way you can load file from resources and parse it for the paths of all the individual assets. I am still not sure why you need the paths to each asset.

Show more comments

3 Replies

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

Answer by $$anonymous$$ · Oct 24, 2012 at 07:50 PM

To come to the conclussion that it is not possible to get the path data inside the Resources.

I have com up with this idea: I named my files in the resources map 'folder-name'

ex: RootFolder/Test/Test-Object

So in this case I can split my name name.Split('-') and get an array of [0] = subfolder [1] = name and this to the resources

Or like RoflHarris said, you can also let a file be generated with the folder structures.

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
avatar image
0

Answer by inewland · May 10, 2013 at 05:24 PM

Also if others are looking for something temporary, I was able to put my files into the StreamingAssets folder and get their path...

 var filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "MyFile");

Note that this doesn't work for all platforms, but I was able to use it on iOS for temporary storage of test files. You may be able to rework this for production.

http://docs.unity3d.com/Documentation/ScriptReference/Application-streamingAssetsPath.html

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
avatar image
0

Answer by Sisso · Jun 19, 2013 at 05:58 PM

Alternatively, for GameObjects you can create a component that identify when a object is in resources and its path. Next you create a Editor script to update all paths.

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

11 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

Related Questions

Resources.Load folders path? 2 Answers

Alternatives to Resources.Load or Refining that command 1 Answer

Store the path with Resources.Load in a string 3 Answers

Access path of stored asset 0 Answers

GetDirectories() does not work on Android 1 Answer


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