public override void OnEnter() { if (useCurrentRes.Value == true || Auto.Value == true) { getResolutions(); } switch (setDepth) { case depthSelect._0: Depth = 0; break; case depthSelect._16: Depth = 16; break; case depthSelect._24: Depth = 24; break; } if (inclGui.Value == true) { _helperTex = (new GameObject("RequestHelper")).AddComponent <RequestHelperTex>(); _helperTex.startEndofFrame(this); } }
public void getPicture() { RenderTexture rt = new RenderTexture(resWidth.Value, resHeight.Value, Depth); gameObject.Value.GetComponent <Camera>().targetTexture = rt; Texture2D screenShot = new Texture2D(resWidth.Value, resHeight.Value, TextureFormat.RGB24, false); gameObject.Value.GetComponent <Camera>().Render(); RenderTexture.active = rt; screenShot.ReadPixels(new Rect(0, 0, resWidth.Value, resHeight.Value), 0, 0); screenShot.Apply(); gameObject.Value.GetComponent <Camera>().targetTexture = null; RenderTexture.active = null; UnityEngine.Object.Destroy(rt); newTexture.Value = screenShot; if (inclGui.Value == true) { _helperTex = null; } Finish(); }