Unity Community

Register or Sign In:

+ Reply to Thread
Results 1 to 6 of 6

  1. Posts
    31

    Path for file:// protocol using WWW class on iPhone

    Hi all,

    My team has a fairly hefty iPhone app that was getting fairly bloated. And even though our assets are under /Resources, the load time is getting so long that sometimes the iPhone shuts the app down with an error about load timeout.

    So since 1.5.1 has opened access to the file:// protocol using the WWW class, we've decided to take all of the textures and some of the art assets and move them into assetbundles for the various versions of the app.

    My assumption was to put our .assetbundle files under the /iPhoneStreamingAssets directory in the hopes that they would be copied to the root of the application on the device.

    The app works great in the editor using this path:
    Application.dataPath + "/../iPhoneStreamingAssets/" + AssetBundleName

    And I assumed that I could use new WWW("file://" + Application.dataPath + "/iPhoneStreamingAssets/" + AssetBundleName) to load the asset bundle on the device.

    However, that doesn't seem to be the case.

    How do I generate the proper path to get to these asset bundles on the actual device?

    Thanks,
    Matt


  2. Location
    Portland, OR
    Posts
    238
    If you right click on a built iPhone app and choose "Show Package Contents", you can see the internal structure of the bundle.

    It looks like stuff in the StreamingAssets folder gets moved to a "/Data/Raw/" directory.

    Maybe this would work?
    WWW("file://" + Application.dataPath + "/Raw/" + AssetBundleName)
    I don't know if Application.dataPath is actually point to that Data directory though. Seems logical, but I've never tried reading anything in there.


  3. Location
    Portland, OR
    Posts
    238
    the load time is getting so long that sometimes the iPhone shuts the app down with an error about load timeout.
    I've been able to get around this by having level 0 be a stub level that does nothing but load another level that is the actual first level. The one frame that that level shows for is enough to let the OS know that you haven't locked up.


  4. Posts
    31
    For the record, if you want to access assetbundles under the iPhoneStreamingAssets folder this works:

    (Application.dataPath.Substring(0, Application.dataPath.Length - 4)) + "Myappname.app" + "/Data/Raw/Yourassetbundlename.assetbundle"

    Looks like there is a bug in the Application.dataPath value that doesn't include the appname, so you have to remove "Data" then append the appname value.

    Thanks,
    Matt


  5. Location
    Portland, OR
    Posts
    238
    That's good to know. When you're reading out of the Documents directory you don't need the 'Myappname.app' part, which is weird.


  6. Location
    Portland, OR
    Posts
    238
    http://developer.apple.com/iphone/li...etworking.html

    This page explains it. Any files inside the app's bundle are accessed from "appname.app/path/to/file"

    Anything else doesn't need it. (e.g. /Documents/path/to/file)

    Basically, Application.dataPath isn't very useful right now, because no matter what you're doing with it you have to scrape off the "/Data" part of it.