more screenshit and fix sunset box grabbing
This commit is contained in:
parent
9e0b3a400b
commit
8f9dd2d571
11 changed files with 197 additions and 87 deletions
3
Assets/fuck/NewAssembly.asmdef
Normal file
3
Assets/fuck/NewAssembly.asmdef
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "NewAssembly"
|
||||
}
|
7
Assets/fuck/NewAssembly.asmdef.meta
Normal file
7
Assets/fuck/NewAssembly.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b04131ef45270a5c495fcdf846f0804a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/fuck/Screenshot.cs
Normal file
32
Assets/fuck/Screenshot.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class Screenshot : MonoBehaviour
|
||||
{
|
||||
public bool takeScreenshot;
|
||||
public string filename = "unity_screenshot.png";
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (takeScreenshot)
|
||||
{
|
||||
Camera cam = GetComponent<Camera>();
|
||||
|
||||
RenderTexture currentRT = RenderTexture.active;
|
||||
RenderTexture.active = cam.targetTexture;
|
||||
|
||||
cam.Render();
|
||||
|
||||
Texture2D Image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height);
|
||||
Image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
|
||||
Image.Apply();
|
||||
RenderTexture.active = currentRT;
|
||||
|
||||
var Bytes = Image.EncodeToPNG();
|
||||
Destroy(Image);
|
||||
|
||||
File.WriteAllBytes("/home/crispypin/pictures/" + filename, Bytes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/fuck/Screenshot.cs.meta
Normal file
11
Assets/fuck/Screenshot.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4733ef1d4170fa3b383a26e80d5538e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue