I have a problem on Google VR, as you can see on the screen shot, on the right eye camera, the UI is double. I didn't do anything in the code, I just created another cam for the UI and culling mask is set only to UI, then this is what happened.
What can I do? Please help!
Related
In my Android-Unity app I have some data such as text, text size, text coordinates etc that I will use to create the output and store it as a screenshot I will later use in my app.
But I need to make this happen when the user isn't seeing the Unity player/scene. So my question is that is it possible to render the contents and then take a screenshot of the same without the user seeing the Unity editor/player/scene whatever one may call it? Is there a way to do it in the background? Thanks!
I'm not sure exactly what you're trying to accomplish but I can clarify the use of a culling mask here. Here is what the scene looks like. I have embedded the view from Camera 2 into the bottom left of the game. You can see that Camera 2 is not displaying the floor. This is because I set it's culling to only respond to objects tagged with a custom layer here. Where as the Main Camera's culling mask is set to everything. Now, anything I tag with the "Custom" layer will be visible in the second camera and everything else would not be. I'm assuming what you want to do from here is to tag the things you want visible when you take a screenshot with a specific layer, then set the Culling Mask of your "Screenshot Camera" to that layer and take a screenshot with that Camera. That way you can specify what Objects/UI want visible in that camera.
In my Google Cardboard project, I have several canvases attached to walls in a room. These canvases have buttons the player can interact with. I set each canvas to World Space, but for some reason, the buttons are rendering in front of objects that should appear in front of the buttons.
update1:
The UI appears behind the cube in the game and scene windows when not running. It's only when I hit play that the image appears in front of the cube. I am adding images to the UI button programatically, but the problem happens even if I add images only using the editor.
update2:
If I disable the cardboard elements in my scene (i.e. use a standard fps camera setup), I do not get the issue.
Picture below: Checkerboard is UI. Gray block is 3D block. I want UI behind the block, on the wall.
Manually move the parent UI object behind the gray object.
Someone on answers.unity3D made this suggestions:
The problem may come from the shader used by the UI element with a
ZTest value set to Off or the Queue tag of the UI element's shader is
"higher" than the tag of the cube's shader
Turns out, and this is apparent in the 3rd screenshot, my UI buttons did not have a material. Once I provided one, I used one that used a standard UI shader (I initially tried unlit, but that made them disappear).
I guess there are still some issues with shaders and google cardboard. Thanks guys
i have the following background and the following main camera , here is the main camera : http://img15.hostingpics.net/pics/681386Untitled1.png
the preview is looks like this : http://img15.hostingpics.net/pics/479945Untitled2.png
i don't get the background and the player in the main camera
please help me solving this problem
Thanks in advance
Your camera's position's Z value is 0, which means your gameobject and camera is on the same plane, so camera can not view it. Change it with some negative value (try -10).
I recently answered a camera problem here so I would check to see if this helps...
Game Object Appears in Scene View but not in Game View
If not, I can see a few warnings occurring at the bottom of the screen shot you posted in Unity, it might be worth addressing those problems first (regarding HDR and rendering paths).
Not sure if this will fix the issue as there isn't a huge amount of info available on your post so it could be a whole range of problems.
Hope this helps :)
I have a camera preview in my android app. As you all probably know it is implemented by a surfaceview in android.
In my photo app, which allows users to take pictures, I want to blur the camera preview (the surface view) if the user has not logged in yet if the user is logged in, I will display the normal preview (without blur)
Blur as something like
But there seems to be no way to do it
Couple things come to mind but I am not sure how to achieve it
use a blur overlay and place it on top of the surface view, but how do u create such blur overlay?
another approach is to change the attribute of the window, but I can't do it to surfaceview,
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
So can we create a window overlay the surfaceview and set the flag like that? I don't think so
can someone tell me how to blur a camera preview, which is a surface view
note: I am trying to blur an area which is the output from camera preview, so it is not like I am blurring a static image, the blur area will change depending on where you point your phone camera
The best way to do this is to take a screen shot of the control, apply a blur to it, and then show that image over the top of the original control. This is how the yahoo weather app does it and its how google suggest you do things like this.
Render script does bluring fast. I've also got some code, but it's not currently at hand right now.
These might help:
http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android
http://docs.xamarin.com/recipes/android/other_ux/drawing/blur_an_image_with_renderscript/
I've also read that there are methods built into Android that do this, but the API isn't public so we cannot use it... which sucks.
Although your 2nd option is losing support in later versions of the Android OS, it may be a good option. I would think to bring a window IN FRONT of your surfaceview, and use the blur_behind property of your now new IN FRONT window.
Android API documentation
"
This constant was deprecated in API level 14.
Blurring is no longer supported.
Window flag: blur everything behind this window.
Constant Value: 4 (0x00000004)"
I do have to admit, Im not 100% sure this would work, but its definitely worth a try.
You have to change the camera parameters; in this case with Camera.Parameters.setPictureSize().
The basic workflow here is :
Camera.Parameters cp = mCamera.getParameters(); // get the current params
cp.set...(); // change something
mCamera.setParameters(cp); // write the params back
Make sure that every resolution that you set via this function is supported. You can get a list of the resolutions that are supported on a device via Camera.Parameters.getSupportedPictureSizes(). and check this Camera documentation.
Does anybody knows, how to cut out camera viewport to smaller size than screen? e.g if I want to have status bar at the top of the screen and moving camera cut only to the area without this status bar? The problem is that camera viewport is always stretched to full screen.
Thanks in advance
Generally the way I do this is by defining two cameras. One for the UI and one for the game world. The UI camera never changes it's position only the world camera moves around.
Then when rendering your UI (assuming you are using SpriteBatch) you simply do this:
batch.setProjectionMatrix(gameCamera.combined);
// ... render your game code
batch.setProjectionMatrix(uiCamera.combined);
// ... render ui code
Just make sure you update your camera as per normal if it has changed via camera.update()