Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

StreamingAssets folder documentation is incorrect for Mac standalone

Discussion in 'Scripting' started by AndyMartin458, Aug 22, 2013.

?

Should Unity update the streaming assets documentation page?

Poll closed Aug 29, 2013.
  1. Yes

    0 vote(s)
    0.0%
  2. No, you shouldn't do this manually anyways.

    0 vote(s)
    0.0%
  1. AndyMartin458

    AndyMartin458

    Joined:
    Jul 15, 2012
    Posts:
    59
    I followed the tutorial here and wanted to hard code the folder locations. I didn't really notice at the time that there was now a function for getting the folder location without having to go the extra mile. Their suggestions are correct for the Unity editor on Mac, but they are false for the standalone.

    http://docs.unity3d.com/Documentation/Manual/StreamingAssets.html

    I recently wrote a blog post http://clubconsortya.blogspot.com/2013/07/loading-connection-data-from-xml.html discussing this, and I hope that no one used my code for a Mac standalone. They must not have because no one e-mailed me to complain. This only took me ohhh 8 hours of coding thinking there was a problem with NGUI before I ultimately realized that the Unity documentation was misleading, well except int that it did say I shouldn't do it the way that I did.

    Can we fix the documentation page?

    Code (csharp):
    1. // For the streaming assets folder
    2. public static string GetPath(string fileName)
    3. {
    4. #if UNITY_IPHONE
    5.  string path = Application.dataPath + @"/Raw";
    6. #elif UNITY_ANDROID
    7.  string path = "jar:file://" + Application.dataPath
    8.           + "!/assets/";
    9. #else
    10.  string path = Application.dataPath + @"/StreamingAssets";
    11. #endif
    12.  //append the name of the actual file
    13.  path += @"/" + fileName;
    14.    
    15.  return path;
    16. }
    17.  
    18. //Update 8/21/2013 This is a more accurate function that will never fail
    19. public static string GetPathUsingUnityWrapper(string fileName)
    20. {
    21.     string path = System.IO.Path.Combine(Application.streamingAssetsPath, fileName);
    22.     return path;
    23. }
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    14,969
    As well as posting it here, did you submit a bug report using the bug report tool? There's a category for documentation bugs too.
     
  3. AndyMartin458

    AndyMartin458

    Joined:
    Jul 15, 2012
    Posts:
    59
    Just tried that, but the bug reporter is crashing :confused:. I'll try again tomorrow.
     
  4. AndyMartin458

    AndyMartin458

    Joined:
    Jul 15, 2012
    Posts:
    59
    OK, I finally got the bug submitted today. It felt really bad when the bug submission had a crash bug.
     
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    14,969
    Did you report that bug? lol

    ;)