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
0
Question by salmanjaved5050 · May 01, 2018 at 07:13 AM · 2d gamestreamingassetsstoragepersistentdatapathdatapath

Streaming Assets or Persistent Data Path for reading files after build.

Hi everyone! I'm making a simple 2d game and in that I need to load images and some audio files from a folder instead of resources. I've heard that streaming assets or persistent data path can be used but I don't know which one will be suitable for me. I've some files already within the persistent data path folder and I want them to be built alongside the game i.e. they come with the game when it is built and are automatically placed in the persistent data path of the computer on which the game is installed. But I've heard that it's not possible and some told me to use streaming assets. So please help which method should I use.

Comment
Add comment · Show 2
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 Harinezumi · May 01, 2018 at 08:12 AM 0
Share

It is unclear what you would like to do: first you write "load images and some audio files from a folder ins$$anonymous$$d of resources", but then "I want them to be built alongside the game".
By default whatever data files you place under the Assets folder (and its subfolders), it will be built into the game, and you can access them in various ways (assigning in Editor, using Resources.Load(), etc.). You don't need Strea$$anonymous$$gAssets or persistent data path for that. On the other hand, if you want to load files added after the project is built, you need to handle that differently, probably accessing the persistent data path.

So which one is it, do you want the resources come with the game, or do you want to add resources after building? Or explain in more detail what you would like to achieve.

avatar image salmanjaved5050 · May 01, 2018 at 08:54 AM 0
Share

Okay just listen to this, I have audio and images inside the persistent data path folder. Whenever my game runs it actually gets the images and audio files from persistent data path. What I want is that all of my images and audio files that are present inside the persistent data path to be built alongside the game and copied to persistent data path of the computer on which the game is run. I want to get data from a folder besides the resources so that's why I asked the question because i'm not sure which one will do the job.

1 Reply

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

Answer by Harinezumi · May 01, 2018 at 10:06 AM

OK, I think now I understand now what you mean. To be sure I understood you correctly, you would like to load images and audio from a folder that is not "encoded" with the application, so that they are visible and maybe even changeable?
If you provide the files yourself, then the StreamingAssets folder is what you want (the persistent data path is rather for storing data between play sessions, for example for save files or data generated through gameplay). The StreamingAssets folder is copied as-is into the build, accessible from the game, but from the file system as well. Here is a great tutorial explaining how to use it for various purposes, including customising your game:
https://www.raywenderlich.com/165809/using-streaming-assets-unity

Comment
Add comment · Show 4 · 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 salmanjaved5050 · May 01, 2018 at 01:44 PM 0
Share

yes that's exactly what I want. But what if I build game for android, where would these assets go and how will I access them?

avatar image Harinezumi salmanjaved5050 · May 01, 2018 at 01:57 PM 0
Share

A quick google search for "unity strea$$anonymous$$g assets folder on android" gave all the answers ;)

Basically on Android you use a WWW operation (which is more general than calls to System.IO) to access a file, constructing the path like this: path = "jar:file://" + Application.dataPath + "!/assets/";. See documentation: https://docs.unity3d.com/$$anonymous$$anual/Strea$$anonymous$$gAssets.html
And the first two answers here give you code examples how it can be done (they will need to be modified to suit your needs).

avatar image salmanjaved5050 · May 01, 2018 at 04:16 PM 0
Share

Thank you so much, I'll try that and see if that works.

avatar image MaxLohMusic · Feb 03 at 10:05 PM 0
Share

What is the benefit of using Application.strea$$anonymous$$gAssetsPath over Application.dataPath?

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

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

Related Questions

Opening data file from asset folder 2 Answers

AppleTV persistanceDataStorage 0 Answers

loading Images from streaming assets in Android 0 Answers

Can't transfer file from datapath to devices 1 Answer

Application.CaptureScreenshot() does not save any image on Android while it does on Editor! 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