Je cherche à faire marcher la fonction CaptureScreenshot(string filename, int superSize = 0); pour mon exécutable.
Voilà mon code, récupéré ICI:
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
using System;
public class ScreenshotMovie : MonoBehaviour
{
// The folder we place all screenshots inside.
// If the folder exists we will append numbers to create an empty folder.
public string folder = "ScreenshotMovieOutput";
public int frameRate = 30;
public int videoSizeMultiplier = 1;
public int imageSizeMultiplier = 1;
private int imageCounter = 0;
private bool videoCapture = false;
private string realFolder = "";
private bool firstCapture = true;
void Start ()
{
Time.captureFramerate = frameRate;
}
void InitFolder () {
// Find a folder that doesn't exist yet by appending numbers!
realFolder = folder;
if (!System.IO.Directory.Exists(realFolder))
System.IO.Directory.CreateDirectory(realFolder);
folder += DateTime.Now.Date.ToString("/yyyy-MM-dd");
int count = 1;
while (System.IO.Directory.Exists(realFolder))
{
realFolder = folder + "-session" + count;
count++;
}
// Create the folder
System.IO.Directory.CreateDirectory(realFolder);
}
void Update ()
{
if (Input.GetKeyDown (KeyCode.H)) {
CaptureImage (true);
}
}
void CaptureImage (bool _isImage) {
if (firstCapture) {
InitFolder ();
firstCapture = false;
}
int sizeMultiplier = imageSizeMultiplier;
string name = string.Format("{0}/image_{1:D4}.png", realFolder, imageCounter++);
// Capture the screenshot
if (Uri.IsWellFormedUriString (name, UriKind.RelativeOrAbsolute))
Application.CaptureScreenshot(name, sizeMultiplier);
else
Application.CaptureScreenshot("toto.png", sizeMultiplier);
}
}
Les dossiers ScreenshotMovieOutput et 2015-11-18-sessionX sont bien créés, les paths sont bons, mais l'image n'est pas créée. Si je ne choisis pas de chemin: Application.CaptureScreenshot("toto.png", sizeMultiplier);, l'image est créée à la racine, sinon rien.
Un petit coup de main, svp?
Merci beaucoup!