x


iPhone: Update Assets from Web?

I'm working on a project where the client wants to be able to update certain text based data assets and maybe select image assets that are stored locally on the phone without needing to issue a formal application update through the iTunes Store. Is this possible?

Assuming any kind of update is possiblem, if there were new icon images to go with things added to the text assets, would it be possible to store entirely new assets?

I'm totally new to iPhone development, and fairly new to Unity as well, so any insight would be appreciated.

more ▼

asked Jul 19 '10 at 10:00 PM

grey gravatar image

grey
34 3 3 8

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can have your app look for new asset bundles from a server and download them if necessary using the WWW class.

From the iphone docs:

var download : WWW;

    var url = "http://somehost/somepath/someassetbundle.assetbundle";

    download = new WWW (url);

    yield download;

    assetBundle = download.assetBundle;

    if (assetBundle != null)
    {
        // Alternatively you can also load an asset by name (assetBundle.Load("my asset name"))
        var go : Object = assetBundle.mainAsset;

        if (go != null)
            instanced = Instantiate(go);
        else
            Debug.Log("Couldnt load resource"); 
    }
    else
    {
        Debug.Log("Couldnt load resource"); 
    }

You can then save the data to a documents folder on the device

Again from the docs:

public static string GetiPhoneDocumentsPath () 
        { 
                // Your game has read+write access to /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents 
                // Application.dataPath returns              
                // /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/myappname.app/Data 
                // Strip "/Data" from path 
                string path = Application.dataPath.Substring (0, Application.dataPath.Length - 5); 
                // Strip application name 
                path = path.Substring(0, path.LastIndexOf('/'));  
                return path + "/Documents"; 
        }

You can also simply download a texture or some text from a website and use them directly in your game without using asset bundles if you prefer. You do this by setting up a new WWW and storing the returned text as a string with www.data

more ▼

answered Jul 20 '10 at 12:13 AM

spinaljack gravatar image

spinaljack
9.1k 18 31 92

I need to test this, of course, but I'm certainly giving you the answer for now! Thanks so much! Super helpful!

Jul 20 '10 at 04:44 AM grey

One brief additional question, if you happen to know, is that documents folder backed-up with the rest of the iPhone data when iTunes does it backup?

Jul 20 '10 at 04:45 AM grey

Backup saves data such as music, applications, podcasts, videos, ringtones, photos, notes, email account settings, contacts, calendars, and bookmarks. So yes, the whole folder.

Jul 20 '10 at 10:38 AM spinaljack
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2013
x513
x427
x426

asked: Jul 19 '10 at 10:00 PM

Seen: 1197 times

Last Updated: Jul 19 '10 at 10:08 PM