unity-camera-viewport-rect
unity-camera-viewport-rect copied to clipboard
Automatically setup Camera viewports from RectTransforms in Unity
Camera Viewport Rect
Automatically setup Camera
viewports from RectTransform
s.
This way one can easily show 3D models directly into responsive UI without the need of setting up RenderTexture
s.
Features
- Supports canvases in both
Screen Space - Camera
andScreen Space - Overlay
modes. UsingScreen Space - Camera
mode is recommended to make sure the camera renders above the UI. - Supports enabling/disabling the target Camera when the script itself gets enabled/disabled
How to install
Either:
-
Install using openupm:
openupm add com.gilzoide.camera-viewport-rect
-
Install via Unity Package Manager using the following URL:
https://github.com/gilzoide/unity-camera-viewport-rect.git#1.0.1
-
Copy the script CameraViewportRect.cs directly into your project
How to use
- Add a CameraViewportRect component to any
object with a
RectTransform
- Set the
Camera
property to the camera that should render inside it - Enjoy 🍾
Samples
This UPM package has the following sample scene:
- RotatingCube: Simple sample with a rotating cube that appears on a responsive UI