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
6
Question by eem · Jun 06, 2011 at 04:35 AM · ioswebplayerassetswindowsstreamingassets

How do I get into my StreamingAssets folder from the various platforms?

I made a 'StreamingAssets' folder inside of my 'Assets' folder and put some things in it which I need at runtime. But I can't quite figure out how to get to it. Whats the proper path and code to use for each platform. Namely, iOS, OSX, Windows and web builds.

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 shayan_315 · Sep 25, 2013 at 02:46 PM 0
Share

i want to make a android game which use $$anonymous$$SAccess Database then i copy my database in Assets/Strea$$anonymous$$Asessts folder (C# language ):i write a function name Read$$anonymous$$B which try to connect to database in windows platform that work well then i understood that i should use www class to access my streams assets folder in android:

 IEnumerator LinkStrea$$anonymous$$gFolder()
 {
 string FinalPath = "jar:file://" + Application.dataPath + "!/assets/" +databasename;
         WWW linkstream = new WWW(FinalPath);
         yield return linkstream;
     read$$anonymous$$DB(linkstream.text);
     } 

which part of my accessing code is wrong? likewise in start function i add this code:

StartCoroutine(LinkStrea$$anonymous$$gFolder());

avatar image robertbu · Sep 25, 2013 at 02:48 PM 0
Share

You should ask your question using a new question, not ask a question as an "Answer" to an existing, and old question that may or may not be the same question. I've converted your answer to a comment and will be deleting it shortly.

5 Replies

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

Answer by maxwelldoggums · Sep 27, 2013 at 06:03 PM

While this is an old question, I feel the need to add this for posterity... Newer versions of Unity have a built in reference to the streaming asset path...

"Application.streamingAssetsPath"

will return the full path to the streaming assets folder regardless of platform.

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 cregox · Sep 27, 2013 at 06:19 PM 0
Share

awesome first post, $$anonymous$$r doggums! ;-)

avatar image michaelhsiu101 · Jan 23, 2017 at 06:56 AM 0
Share

This worked for me on PC builds when Application.dataPath + "/Strea$$anonymous$$gAssets" didn't work!

avatar image
8

Answer by kdubb · Jun 06, 2011 at 05:00 AM

Most everything is the same, except on the mobile platforms...

Default = Application.dataPath + "/StreamingAssets"

iOS = Application.dataPath + "/Raw"

Android* = "jar:file://" + Application.dataPath + "!/assets/"

*Android packages are delivered as jar (aka zip) files and are never unzipped (as per the Android platform). This means that on Android the Application.dataPath just points to the jar file itself. This also means you must use something that can access zip files to get at your assets. Unity's WWW class will do this and the base path specified above will work properly with it; just append your file path/name to it.

Comment
Add comment · Show 9 · 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 eem · Jun 06, 2011 at 07:02 AM 0
Share

Application.dataPath + "Strea$$anonymous$$gAssets" is not giving me access to my assets. However something new has come to my $$anonymous$$d as to what might be the issue. If a class extends nothing and is not Static, will it be included into a build of the game?

I am trying to stream an xml file from my strea$$anonymous$$gAssets folder into a class that is neither $$anonymous$$onobehavior, ScriptableObject nor static. Is that perhaps the reason why? This class isn't being included in a build?

avatar image kdubb · Jun 06, 2011 at 07:08 AM 0
Share

I updated my answer... in my first attempt I had forgotten the path separators (I copied my code which uses the Path.Combine method to join the path components), Does that fix your problem?

To answer the question you asked in the comment... no that shouldn't be a problem. I have text (JSON not X$$anonymous$$L) files in my Strea$$anonymous$$gAssets folder and can load them just fine.

avatar image eem · Jun 06, 2011 at 08:21 AM 0
Share

Alright I did a test and confirmed the issue is not my class. But it still doesn't work and I'm really at a loss here...

the exact path I am using is this

Application.dataPath + "/Strea$$anonymous$$gAssets/Data/Global.xml"

the file is clearly in my Strea$$anonymous$$gAssets folder, it loads just fine inside the editor, but won't load from a windows build or a web build

avatar image eem · Jun 06, 2011 at 08:13 PM 1
Share

Oh no no. 'Data' is a folder I have inside my Strea$$anonymous$$gAssets folder. In the literal folder hiearchy the file is at /Strea$$anonymous$$gAssets/Data/Global.xml

Could that be the issue? Can you not make folders inside strea$$anonymous$$gAssets?

avatar image Neutron · Jul 11, 2012 at 06:26 AM 1
Share

Windows uses "\\" not "/" as a folder separator. $$anonymous$$aybe that's your problem.

For cross platform compatibility use the Path.Combine method to create file paths rather than hard coding the separator into a string.

Show more comments
avatar image
3

Answer by aeldron · Apr 03, 2014 at 03:34 PM

 string GetStreamingAssetsPath()
 {
     string path;
     #if UNITY_EDITOR
     path = "file:" + Application.dataPath + "/StreamingAssets";
     #elif UNITY_ANDROID
     path = "jar:file://"+ Application.dataPath + "!/assets/";
     #elif UNITY_IOS
     path = "file:" + Application.dataPath + "/Raw";
     #else
     //Desktop (Mac OS or Windows)
     path = "file:"+ Application.dataPath + "/StreamingAssets";
     #endif
     
     return path;
 }

I wonder why Unity didn't make the Application.dataPath return the correct prefix in the first place.

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 AlanMattano · Jun 15, 2020 at 08:21 PM 0
Share

Comment note: Did you mean Application.strea$$anonymous$$gAssetsPath ins$$anonymous$$d of Application.dataPath?

avatar image aeldron AlanMattano · Jun 15, 2020 at 08:46 PM 0
Share

This is a very old thread (2014). At the time they didn't have an Application.strea$$anonymous$$gAssetsPath

avatar image
1

Answer by DiebeImDunkeln · Feb 23, 2015 at 03:56 PM

is it possible to download files to the StreamingAssetsPath?

Comment
Add comment · Show 1 · 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 AgentMilkshake1 · Jun 28, 2017 at 04:32 PM 0
Share

$$anonymous$$ight be a bit late for you, but I would recommend creating a folder within Application.persistentDataPath. This will (at least on mobile devices, not sure about PC/$$anonymous$$ac) allow you to download files and then save them using System.IO.

For example:

 public IEnumerator $$anonymous$$yDownloadCoroutine()
 {
 // Specify the download URL.
 string myDownloadURL = "http://www.downloadlocation.com";
 
 // Create and start a webcall to the download location.
 WWW downloadWebCall = new WWW(myDownloadURL);
 
 // Wait for the download to be done. You can check progress via 
 //the WWW.progress variable which is a float between 0 and 1.
 while (!downloadWebCall.isDone)
 {
 yield return null;
 }
 
 // Define a directory path, on Android this will end up being something
 // like "Device/Android/data/com.mycompany.appname/Files/UserDownloads/"
 string directoryPath = Path.Combine(Application.persistentDataPath, "UserDownloads");
 
 // Define a file path, must include the correct file suffix (.png, .zip, etc.)
 string filePath = Path.Combine(directoryPath, "myDownloadedFile.zip");
 
 // Check if the directory exists. If not, then create it.
 if (!Directory.Exists(directoryPath))
 {
 Directory.CreateDirectory(directoryPath);
 }
 
 // If you want to force the file to always be the new downloaded version.
 // This finds if the file already exists, and if it does, deletes it.
 if (File.Exists(filePath))
 {
 File.Delete(filePath);
 }
 
 // Write the downloaded file bytes to the specified file path.
 File.WriteAllBytes(filePath, downloadWebCall.bytes);
 
 }
avatar image
-1

Answer by shayan_315 · Sep 29, 2013 at 12:03 PM

but you can not retrieve your data directly from your asset folder !! i read in many post but iam surprised why nobody make simple example with www class to load data from apk? most of respondents do not have any experience about making simple example and only like us read unity Streamingassets part then please please make a simple app which only read hello world from streaming assets folder in android (apk) we do not need hint like this at least not any more ,just example please

Comment
Add comment · Show 1 · 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 cregox · Sep 29, 2013 at 04:39 PM 0
Share

now, how's that an answer? you are not reading anything right, sir, and there's not much anyone here can do to help you with that. maybe you could start again with the manual.

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

13 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

Related Questions

Best way to Port Unity Windows project to iOS 0 Answers

Windows Editor Extension error with iOS Player 0 Answers

Accesing StreamingsAssets in android (LitJson) 1 Answer

working with mp4 files when supporting both Standalone and iOS builds 1 Answer

What is best way of Creating an iOS app build in Windows and Then on the Mac 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