Search Unity

Download texture from web and save to device.

Discussion in 'Scripting' started by iceshaft07, May 25, 2011.

  1. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    I am writing code to contact my server, download a file filled with PNGs, and then display them on a model. This is how I intend to do inApp purchases.

    I have two questions:
    I plan on using that SetPixels function to copy the pixels to the table on our texture atlas.

    Code (csharp):
    1.  
    2.     newTable = Resources.Load(tableToLoad) as Texture2D;
    3.     if (newTable != null  currentTable != null)
    4.     {
    5.         currentTable.SetPixels(tableRect.x,tableRect.y,tableRect.width,tableRect.height,newTable.GetPixels(0,0,tableRect.width,tableRect.height));
    6.         currentTable.Apply();
    7.     }
    8.  
    Therefore, I need to make sure the content downloaded is RGB24, and writable, and not scaled to nearest power of 2. Is there somewhere I should look at to do this? (The game will be running, so I can't use editor scripts)

    Second, how do I save it? I've poked around the forums looking for it. I am pretty sure I don't want to use playerprefs for this, and as far as the iPhone goes, I've seen things about only being able to save in the documents directory.

    Can anyone help me get started?
     
  2. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
  3. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Did you succeed in figuring something out about this? I am trying to do something similiar.