Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[HELP] Saving Image With an id

Discussion in 'Scripting' started by WirealTalha, Sep 16, 2019.

  1. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
    Hi, I would Like to know How to Save an image to the device with an ID?

    scenario: I'm downloading 50 images from web and saving them on device.(images are small) but they are used frequently.( for each client the images are different).

    So What I know so far is that i should be encoding the images to png (byte arrays). But how do I assign ids to the images?

    https://docs.unity3d.com/ScriptReference/ImageConversion.EncodeToPNG.html

    would this method work? I'm new to file management kindly put me in the right direction please.

    File.WriteAllBytes(Application.dataPath + "/Myimages/"+ID+".png", bytes);
     
  2. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
  3. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    What you posted in the first comment should work. Have you tried it and found it to not work?
     
    WirealTalha likes this.
  5. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
    I have yet to try it out. I just wanted to take opinions on how this is normally done.