- Home /
Question by
deets · Jan 03, 2018 at 02:12 PM ·
webglscreenshot
CaptureScreenshot WebGL
Hi,
I'm trying to Capture a screenshot of my game to use in the user interface. Loading a texture from resources and using it on a plane already works.
capturing a screenshot works in the editor, but when I build for WebGL I keep receiving the error "Failed to store screen shot" and I have no idea how to fix it. Tried a few things already, but none seem to work.
Here you can see my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DebugUser : MonoBehaviour
{
public Material MatScreenshot;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown("j"))
{
ConfigurationManager.Instance.ConfigurationToJson();
}
if (Input.GetKeyDown("l"))
{
ConfigurationManager.Instance.JsonToConfiguration(null);
}
if (Input.GetKeyDown("t"))
{
ScreenCapture.CaptureScreenshot(Application.dataPath);
}
if(Input.GetKeyDown("y"))
{
Texture screenshot = Resources.Load("UnityScreenshot") as Texture;
MatScreenshot.SetTexture("_MainTex", screenshot);
}
}
}
Comment
The docs for ScreenCapture.CaptureScreenshot() show the parameter is a filename, not a path (which is simply a folder) as you provided. I suspect you need to specify the NA$$anonymous$$E to be assigned to the screenshot FILE, like "UnityScreenshot".