https://github.com/gilzoide/unity-camera-viewport-rect
Automatically setup Camera viewports from RectTransforms in Unity
https://github.com/gilzoide/unity-camera-viewport-rect
3d camera recttransform responsive ui unity unity3d viewport
Last synced: 4 months ago
JSON representation
Automatically setup Camera viewports from RectTransforms in Unity
- Host: GitHub
- URL: https://github.com/gilzoide/unity-camera-viewport-rect
- Owner: gilzoide
- License: unlicense
- Created: 2022-11-08T16:42:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-20T00:09:28.000Z (about 2 years ago)
- Last Synced: 2025-03-17T05:11:32.583Z (4 months ago)
- Topics: 3d, camera, recttransform, responsive, ui, unity, unity3d, viewport
- Language: C#
- Homepage:
- Size: 3.93 MB
- Stars: 38
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Camera Viewport Rect
[](https://openupm.com/packages/com.gilzoide.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` and `Screen Space - Overlay` modes.
Using `Screen 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](https://openupm.com/):
```
openupm add com.gilzoide.camera-viewport-rect
```- Install via [Unity Package Manager](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using the following URL:
```
https://github.com/gilzoide/unity-camera-viewport-rect.git#1.0.1
```- Copy the script [CameraViewportRect.cs](Runtime/CameraViewportRect.cs) directly into your project
## How to use
1. Add a [CameraViewportRect](Runtime/CameraViewportRect.cs) component to any
object with a `RectTransform`
2. Set the `Camera` property to the camera that should render inside it
3. Enjoy 🍾## Samples
This UPM package has the following sample scene:
- [RotatingCube](Samples~/RotatingCube/RotatingCubeSample.unity): Simple sample with a rotating cube that appears on a responsive UI