Screenshot is uploading wrong

Hi,

I want to make a screenshot and upload it to a folder, but it only uploads the photo’s to my folder screenshots when I select a different application during runtime.

For example, I have pressed “n” 3 times, and nothing is in my screenshots folder, and when I select a different application like google chrome, and then return to Unity3D, the files are uploaded.

Do I need to put this code in a different Monobehaviour message, or is there some other way to fix this?

void Update(){
    if(Input.GetKeyDown("n")){	//Take a screenshot and upload it to the Screenshot folder
             screenshotName = GenerateScreenshotName();
             Application.CaptureScreenshot("Assets/Screenshots/"+screenshotName+".png");
             Debug.Log("Uploaded screenshot");
  }
}

Thank you!

The Assets folder only exists in the editor. It’s not good idea to write to this location, since it’ll fail in your final game build. Also, not all platforms allow you to write files.

Unity doesn’t expect the game to write files into Assets. Alt-tabbing to Chrome and back tells Unity to check for new files. (Think about it this way, you might have alt-tabs to file manager and copied files around. When you alt-tab back to Unity, Unity looks for changes.)