Camera Feed on Background — Unity Asset — Mobile Camera Stream — Device Camera
Camera Feed on Background — Unity Asset that uses Back/Rear or Front/Face Camera on the player’s mobile device to display the Live Video Input on the Background of the Scene. Safety First.
It doesn’t use any Motion Sensor of a Mobile Device (Gyroscope or Accelerometer) to rotate the Game World like in AR Camera Lite (docs) or in AR + VR: MR Camera (docs).
Contents
Features of Camera Feed
Bring the enchanting Power of Camera Feed into your amazing Game or App:
- Cross-platform Camera Feed: iOS, Android.
- Device Orientations: Portrait, Landscape.
- Smartphone Cameras: Rear/Back, Front/Face/Selfie.
- Button: Switch Camera (Back/Front).
- Instant Launch after granting the camera permission.
- Quick Testing in Unity Editor with Web Camera.
Package Contains
- Demo Scene with Camera Feed.
- Menu Scene with Safety Tutorial.
- Permission Scene with Camera Permission Request using free Native Camera.
- Loading Screen to switch scenes seamlessly.
Check the Map of Unity Assets to choose the product that best suits your needs.
Limitations
Asset doesn’t operate with Native Code and relies on WebCamTexture class.
Any possible Limitations are related to this class.
Known Issues
- WebCamTexture lags after Device Orientation is Changed — Bug in Unity Engine: can be detected on some mobile devices when orientation changing or camera switching. Solution: use the only orientation in your game without changing it and without camera switching during the game. Successful examples without this bug and with using the only orientation: AR Shooter, MR Camera.
- [iOS] Logs don’t show up in Xcode when using WebCamTexture Class — Bug in Unity Engine.
Solution: You can use Console in Unity Editor to connect to the iPhone remotely and see the log. - Black Screen on iOS. Solution: You just need to fill Camera Usage Description in Unity Editor:
File > Build Settings > Player Settings > iOS > Other Settings > Camera Usage Description.
Use Cases
1. With adding rotation of the Game Camera with the Motion Sensor of a Mobile Device (Gyroscope or Accelerometer), Camera Feed on Background can be used as a “Pseudo AR Camera” to display 2D or 3D objects as though they were in the real world.
This technique was implemented in AR Camera Lite (docs).
2. With integration of Google Cardboard XR Plugin, the Camera Feed on Background can be used as a Mixed Reality (MR) Camera. This idea was implemented in AR + VR: Mixed Reality Camera (docs).
3. AR Shooter (docs).
Tutorial
This tutorial is relevant for Camera Feed on Background 2.0+.
Tutorial for the previous version can be found only in the asset folder.
Getting Started with Camera Feed on the Background
Folders & Files in the package by default:
- Makaka Games.
Steps
If you have any issues with the first launch, then just Reach Support with Invoice Number and Get Help.
If you read this tutorial from PDF, first check the latest docs online to get actual information.
- Create New Unity Project with Unity 2022.3.18 & “3D” Template.
- File > Build Settings > iOS or Android > Switch Platform.
- Next Packages must be manually installed with Git & Unity Package Manager:
- Download and import Camera Feed on Background into Unity.
- Window > TextMeshPro > Import TMP Essential Resources.
- Reopen Unity Project.
- Open Scene: Makaka Games > Camera > Camera Feed On Background > Scenes > Demo.
- File > Build Settings > Add Scenes to build:
- Menu,
- Permission_Camera (from Makaka Games > Permissions > Camera > Scenes),
- LoadScreen (from Makaka Games > Publisher > Everyday Tools > SceneControl > Scenes),
- Demo.
- Option: Limit the Screen Orientation from Auto (by default) to the Portrait only or Landscape only by indication of appropriate Scene Loading Methods on the corresponding buttons that cause a transition to another scenes. Orientation in the Player Settings is used for the 1st scene in the build.
- Option: File > Build Settings > Development Build > Check (to See the Log in the Console).
- File > Build Settings > Player Settings > iOS > Other Settings > Camera Usage Description > Fill it (any notice for your app).
- Test in the Unity Editor or Build for Mobile.
Useful Article: How to Test iOS App without Developer Account?
Placing Visible Game Objects
If you need to place visible Non-UI Game Objects over the Device Camera Feed, then just Activate the Game Object called Game World, and place Game Objects inside it.
Game World contains a separate Camera for this task: Main Camera.
After activating, you will have 2 Game Cameras in the Scene:
- Background Camera (UI Layer) for Device Camera Feed and UI.
- Main Camera (other Layers) for visible Non-UI Game Objects.
Game Objects will not move based on Device Movement.
Use AR Camera Lite (docs) or AR + VR: MR Camera (docs) instead.
Feed FPS and App FPS
The Unity Package has a Prefab called CameraFeedOnBackground that is already customized for the best experience in the Demo Scene.
You can customize the Prefab Instance on the Scene with Target FPS of Camera Feed and App:
these 2 types of Frames Per Second (Frame Rate) are set independently of each other:
- Camera Feed will use the closest supported FPS. Zero (0) FPS will lead to Value by Default.
- The App will strive to use Target FPS.
Testing
You can test Camera Feed quickly in Unity Editor without a Smartphone through physical Web Camera.
Tested with Devices
- iOS on iPhone XS Max.
- Android on Samsung Galaxy A71.
If you need WebGL support, please use a 3rd party asset called Device Camera WebGL.
Support
First, read the latest docs online.
If it didn’t help, get the support.
Changelog
Check the current version of Camera Feed on Asset Store.
The latest versions will be added as soon as possible.
2.0:
Features:
- Button: Switch Camera (Back/Front).
- Unity Event OnCameraSwitched() is exposed in Inspector.
Improvements:
1.3:
Features:
- Front Camera Support.
1.2:
Improvements:
Fixes:
- Zoom Effect of Camera Feed in Vertical/Portrait Mode.
1.1:
Features:
- Horizontal/Landscape Mode support.