static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Profiling.Experimental.DebugScreenCapture o;
         o = new UnityEngine.Profiling.Experimental.DebugScreenCapture();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
예제 #2
0
    static void ScreenshotCallback(string fpath, bool isSuccess, UnityEngine.Profiling.Experimental.DebugScreenCapture debugScreenCapture)
    {
        Debug.Log(fpath);
        Debug.Log(isSuccess);
        Texture2D texture = new Texture2D(debugScreenCapture.width, debugScreenCapture.height, debugScreenCapture.imageFormat, false);

        try
        {
            var bytes = debugScreenCapture.rawImageDataReference.ToArray();
            texture.LoadRawTextureData(bytes);
            var pngData = texture.EncodeToPNG();
            var path    = System.IO.Path.GetFileNameWithoutExtension(fpath) + ".png";
            System.IO.File.WriteAllBytes(path, pngData);
        }
        catch (Exception e)
        {
            Debug.Log(e);
        }
    }