daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     void LateUpdate()
  2.     {
  3.         if (snapCam.gameObject.activeInHierarchy)
  4.         {
  5.             Texture2D snapshot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
  6.             snapCam.Render();
  7.             RenderTexture.active = snapCam.targetTexture;
  8.  
  9.             snapshot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
  10.             byte[] bytes = snapshot.EncodeToPNG();
  11.             string filename = SnapshotName();
  12.             System.IO.File.WriteAllBytes(filename, bytes);
  13.  
  14.  
  15.             if (count == 50)
  16.             {
  17.                 count = 0;
  18.             }
  19.             snapCam.gameObject.SetActive(false);
  20.         }
  21.     }
  22.     string SnapshotName()
  23.     {
  24.         count++;
  25.         return string.Format("{0}/Resources/{1}.png",
  26.             Application.dataPath,
  27.             count);
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top