Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

WebGL build: writing to disk, PlayerPrefs, etc...

Discussion in 'Unity 5 Pre-order Beta' started by Jagwire, Feb 6, 2015.

  1. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    When thinking about saving player state across scenes for a WebGL solution, can we still write to disk as we would from a Desktop build? Is there another solution outside of AJAX calls with state saved on a remote machine?
     
  2. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
  3. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    @Onsterion
    I think that would be a good option for PlayerPrefs, but my particular use-case is a local log file which might not make a whole lot of sense as key-value pairs. Other thoughts?
     
  4. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    You cannot directly write files to disk from Javascript, it would be way too much of a security risk.
     
  5. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    @PhobicGunner
    Yes. How might you consider creating and storing log data in a WebGL powered solution?
     
  6. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Depends. Who needs to get access to the logs?
     
  7. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    @PhobicGunner
    Researchers as a post-process, nothing in realtime.
     
  8. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Could always have a web server running somewhere and a PHP script. Client gathers log data, and then at the end of a session it POSTS said log data to your PHP script which saves it as a text file on your server.
     
    DanSuperGP likes this.
  9. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I believe System.IO works, or will within WebGL. The difference is that you wont be writing to disk, but rather the browsers isolated store which is essentially a database.
     
  10. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    The entire System.IO namespace?
     
  11. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'm not positive, I just thought I had read that somewhere...