Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

Download and store pernanent data on device

Discussion in 'Scripting' started by GreenGaming, Sep 17, 2012.

  1. GreenGaming

    GreenGaming

    Joined:
    Sep 10, 2012
    Posts:
    5
    Hi guys,

    I'm looking to store assets on a server and download it as asset from the game later.

    I already know how to download them and store them, but not as permanent datas.

    The point is to reduce the size of the apk on the device (and also on iOs if possible) and download later the packages needed for the next in game level.

    For example I've the texture pack "Texturepack1" stored on the server, and I want to download and store it on the device as permanent data and not as cache or just saving it in game.

    I don't know if there's a way to do that. I've already done a lot of tutorial and personal test with the bundle asset but I haven't find yet a way for that.

    Thanks.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    The Application.persistentDataPath property returns a path to a folder where data can be stored between sessions. You can use the classes in the System.IO namespace of the .NET library to store data after it has been retrieved from a download, although the complexity of the task might depend on the type of data you are working with.
     
  3. GreenGaming

    GreenGaming

    Joined:
    Sep 10, 2012
    Posts:
    5
    Hi Andeeeee,

    Thanks for your answer, I'm working on it right now,
    I'll keep in touch and post parts of the codes if it's working.
     
  4. GreenGaming

    GreenGaming

    Joined:
    Sep 10, 2012
    Posts:
    5
    Hey I'm back !

    Just to tell that I found a way for what you said but I didn't use System.IO.

    At first I downloaded the asset bundle on the phone and then I stored it on the cache.

    And now I'm calling the package every time I need them.

    What I'm doing now, I'll stream scenes because we are looking for considerably reduce the size of the apk and download later all the levels.

    Btw I'm Currently working on Android iOs.

    Should I post codes here ? (I'll not post all codes but the mains functions)

    Thanks Again Andee.
     
  5. GrannySmith

    GrannySmith

    Joined:
    Jul 20, 2012
    Posts:
    8
    Hey GreenGaming,
    can you further explain what you did exactly and maybe post some code? I am desperately trying to do the same as you. I really need to download some assets and store them permanently on the disk (iOS and Android but iOS is more important). And everytime i start the app i want to retrieve the assets/the whole assetbundle from the filesystem and if it is not available i want to download it from the server. Any suggestion on how to do this?

    thanks in advance