Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LateUpdate()
- {
- if (snapCam.gameObject.activeInHierarchy)
- {
- Texture2D snapshot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
- snapCam.Render();
- RenderTexture.active = snapCam.targetTexture;
- snapshot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
- byte[] bytes = snapshot.EncodeToPNG();
- string filename = SnapshotName();
- System.IO.File.WriteAllBytes(filename, bytes);
- if (count == 50)
- {
- count = 0;
- }
- snapCam.gameObject.SetActive(false);
- }
- }
- string SnapshotName()
- {
- count++;
- return string.Format("{0}/Resources/{1}.png",
- Application.dataPath,
- count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement