My all project works in UI. One of my scene has videoPlayer and I would like to set my MainCamera to that specific Area. This scene is my Recording scene but for recording I have to use canvas Render Mode and has to be "Screen Space - Camera". How I can set my camera view to that specific area.
I tried 2nd camera with culling mask but didn't work because videoplayer is already my UI's child when camera Renders UI showing all children objects.
Is it possible show to camera whereever I want in UI?
enter image description here
Yessir it sure is. I literally had to do this a couple of days ago. Here is a tutorial/video I followed to figure out how to do it for my application. From the sounds of it, all you need to do is follow the video up to ~3 minutes. Then utilize the end product of getting a camera to showcase something in a UI window for your application.
For reference if the video gets deleted the process is as follows:
Create a new GameObject within the Canvas
Add a Raw Image as a child to to the new GameObject
We want a raw image because Raw Images in particular support the addition of a 2d Texture and this is what we need in order to display the Camera view.
Add a new Camera as a child to the GameObject
Create a new Render Texture in you Project Folder
Add the Render Texture to your Camera's Camera Component in the Target Texture field
Add the Render Texture to you Images Raw Image Component in the Texture field
Move the Camera to what you want to view and it should project to your UI GameObject.
If it doesn't do this correctly or the image has weird aspect ratios, check the dimensions in the Render Texture and your Image. It took me a while to get everything to look normal but it really just takes dimension adjustments.
Hope this helps!
Related
I am new to Unity and am working on a UI project. I want to add a Camera targeted on a GameObject in the Canvas. There is a Camera with the same hierarchy of the Canvas and when I clicked it the preview is blank but when I play the project everything is shown, including all the buttons texts images.
How does the Camera work with UI and is it possible to add a camera targeted on a GameObject?
For your main Canvas, you do not need a Camera. Please see the Unity Manual for information regarding the Canvas. Take note of the Render Mode option on the Canvas Component. If this is set to Screen Space - Overlay then you will not need a camera to view UI Items or GameObjects that are placed as children to this GameObject. It will also inherently not appear in your Camera Preview if it is located under a Canvas of this type.
If you would like to have other GameObjects show up in the Camera Preview, add them to your scene and ensure that they are not under the Canvas GameObject. Then ensure that they are in range of your Camera.
Hope this helps!
Basically, there is a problem with ARFoundation package in Unity3D.
At first, I generate avatar model from the AvatarSDK. Not really important at this problem. but anyway. It returns skinned mesh renderer with blendshapes.
What I want to do next is to control those blendshapes with my own face through front camera. For this, on my scene I loaded ARSession/ARInputManager, ARSessionOrigin/ARFaceManager.
Then, when by model is generated, I enable ARFaceManager component to track face.
What I see next is front camera image with my virtual model on it.
The problem is I need to track face by front camera, but I do not want to see front camera image on screen.
Can it be solved?
In order to do this, you need to create a new skybox cubemap material first.
After you've done so, navigate to AR Session Origin > Main Camera in your hierarchy and find the AR Camera Background component.
Click the Use Custom Material checkbox and load your newly created skybox material as the custom material.
This will override the default camera material setting.
Good luck!
I like to play animation on a Canvas.
I made a canvas as shown in the following image.
I like to play a golfer animation on the green color canvas.
Is it possible?
I have animation model as shown in the second figure.
I like to play that golfer animation on the canvas.
How can I do that?
I drag and put under canvas as child object, it doesn't work.
As I explained in my comment, I would do as follow :
Put your object in a specific layer (called MyLayer for the sake of the example)
Set the Culling mask of a new camera to render only this specific layer
Uncheck the MyLayer in the Culling mask of your main camera in order to prevent the latter to render your model
Set the Clear flags to Depth only of the camera to prevent the latter from rendering the skybox
Create a new Render texture in your project, and drag & drop it in the Render Texture field of your new Camera
Add a new Raw Image to your UI canvas and assign the render texture in the Texture field
Run your 3D animation
Your camera will render the animation into the image on your UI
I am working on a Unity 2D board game similar to WordFeud: a gameboard with tiles (UI Image prefabs generated with code), with underneath the board a user interface with draggable tiles, buttons, scores etc. I want to zoom in on the game board by double tap on the screen.
The game scales with the device resolution using the canvas scaler option as demonstrated here:Charger Games. For the zoom I have added a second camera that renders its output to a render texture as explained here:Gamasutra. The render texture will eventually take the position of the game board. In the example screens attached it is a bit smaller than the full board to show what's happening.
In the trial setup I am able to perform the zoom with the second camera on a sprite (dragged to the scene) but the second camera fails to render a UI Image element if added to the scene. Yet this is what my game is composed of: UI Image elements.
Question: how do I get the second camera to show UI Image elements on the render texture?
Attached an image with combined screen dumps of the setup. From left to right: 1) the main canvas with the scaler enabled (it uses the UI image - game board to fill the background), 2) second camera setup (note that camera preview shows the Wordfeud sprite, but not the UI Image test), 3) params of WordFeud sprite, 4) params of UI Image test, 5) params of RawImage - render texture (this is a child of Minimap canvas).
I does not matter if I put the sprite or the UI Image in the default layer or the UI layer, the result in both cases is the same: the sprite is rendered, the UI Image is not.
Unity version 5.3.3.f1
This is my first time with unity, I need to make a 3d object in the camera of the device (vr) in certain coordinates of a map, do you know any links that can help me? Is only a static object will always be in the same position and users will be able to see it on their devices
If this is to be overlayed above a 3D scene use a renderTexture, then add the rendered texture to the UI using a Raw Image component.
Another way to do this is to use a canvas set to screen space overlay rendering. You can create a canvas by going to GameObject > UI > Image.
(see page for UI>canvas on Unity manual site, I can only post 2 links as a new user)
The canvas in this rendering mode is described this way on the unity manual page for the UI Canvas:
Screen Space - Overlay
This render mode places UI elements on the screen rendered on top of the scene. If the screen is resized or changes resolution, the Canvas will automatically change size to match this.
I am assuming this is a UI element over a 3D scene, because you mentioned VR.
Credit: I got some of my links and info from the unity forum thread "What is the best way to display 3D models as UI elements?"