Class CameraExtensions
UnityEngine.Camera Based Extension Methods
Inheritance
Namespace: GDX
Syntax
[VisualScriptingCompatible((short)2)]
public static class CameraExtensions
Methods
| Improve this Doc View SourceRenderToPNG(Camera, String, Int32, Int32, Int32)
Forces a UnityEngine.Camera through RenderToTexture(Camera, Int32, Int32, Int32) encoding to PNG.
Declaration
public static bool RenderToPNG(this Camera targetCamera, string outputPath, int width = 1920, int height = 1080, int depthBuffer = 24)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Camera | targetCamera | The target UnityEngine.Camera to use. |
System.String | outputPath | The full path to output the PNG bytes. |
System.Int32 | width | The desired width of the rendered texture. |
System.Int32 | height | The desired height of the rendered texture. |
System.Int32 | depthBuffer | The desired depth of the rendered texture. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the capture was successful. |
Remarks
This does not indicate if the writing of the PNG was successful.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
RenderToTexture(Camera, Int32, Int32, Int32)
Forces a UnityEngine.Camera to render it's view into a texture.
Declaration
public static Texture2D RenderToTexture(this Camera targetCamera, int width = 1920, int height = 1080, int depthBuffer = 24)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Camera | targetCamera | The target UnityEngine.Camera to use. |
System.Int32 | width | The desired width of the rendered texture. |
System.Int32 | height | The desired height of the rendered texture. |
System.Int32 | depthBuffer | The desired depth of the rendered texture. |
Returns
Type | Description |
---|---|
UnityEngine.Texture2D | The rendered view. |
Remarks
This behaves differently then using UnityEngine.ScreenCapture.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |