saving screenshots

Hi,

I would like to create a screenshot when a player quits or disconnect the game, so when the player comes back, he will see a small screenshot of the last frame rendered by unity. Any one knows how?

Comments

  • More of a general Unity question but probably try this
    public void OnApplicationQuit()
    {
     Application.CaptureScreenshot("Screenshot.png");
    }
    

    edit:
    public void OnDisconnectedFromPhoton() 	
    {
     Application.CaptureScreenshot("Screenshot.png");
    }
    
  • ok but but where is this screenshot located? I assume its client?

    http://unity3d.com/support/documentatio ... nshot.html

    because this page says :

    This function does nothing if used from inside the web player or a Dashboard widget.

    any ideas?
  • I am guessing it's one of:
    Application.dataPath Contains the path to the game data folder (Read Only).
    Application.persistentDataPath Contains the path to a persistent data directory (Read Only).
    Application.temporaryCachePath Contains the path to a temporary data / cache directory (Read Only).
    But you could ask over in the Unity forums instead.
  • But this works for the webplayer ??
  • No, in the webplayer you must send it to a webservice, you can't store anything on the system at all that you generate at runtime
  • So does anyone knows if its able to create a screenshot of the last frame when a player drops out of the game? I have tried this using www and OnApplicationQuit, but this only works inside the editor, not in browser:S

    Issnt there really no other way of doing this?
  • OnApplicationQuit is not usable in the webplayer, you must generate screenshots constantly and send them cause at the point of OnApplicationQuit you have between 'no' (chrome and I think FF terminate plugins instantly as such OnApplicationQuit will not even terminate anymore) and 'very very little time' independent of what you do though you NEVER will have enough time to send an image to a webservice
  • What about saving data when a player drops out? I want to save data to mysql when a player stops playing... This should be possible right?
  • If its not done against a webservice but by your own hosted photon server or the master client to a webservice then yes.
    But the leaving player will potentially not have enough time left to perform it
  • Okay so the masterclient can upload the data then as i understand? but what if there;s only 1 player thas IS the master?
    And why own hosted photon server? Its not able to do with cloud?

    Thanks
  • If you work with the cloud then the master client can and must do it.
    if he is the only one then it will logically not work unless you run master clients on a dedicated machine that are available 24/7 or alike.

    The pointing out on own server was in case you want the photon server to do it. As the cloud is 'untouchable' in the sense that you can't run own code, you would need to run your own photon server if you want to let the photon server handle it instead of any client at all