how can I create Menu in my application , I use canvas , but Gear VR Camera dosent see it .
is there way , to use button in gear application
3d text appear but not canvas text
Never use screen space ui with VR, switch to world space and either place it somewhere in the scene (as a "real" object) or parent it to the camera so it is always in the center of the viewport.
ChanibaL is right, canvas can not be used in screen space.
Last time, when I design a menu in vr. I add sphere out of the camera, with a full black color. And put the ui buttons inner the sphere as a menu.
I think this may help for you.
More about UI design in vr, I advice to read this post UI for VR
Related
I'm trying to display some Particles and Slider (like a health bar) over a GameObject in Unity 2020.3.26, but even if in the Scene it's showing like I want, when playing, the canvas seems to orient itself "too much" and I don't know how to make it so both the Particles and Slider stays in place.
As shown in the images, I've put a canvas in a GameObject "Aimable Target Body", and when I look at the center of the object it works as I want.
But if I start looking away, instead of staying centered, the UI goes a little away (don't mind the big blue magic circle in the middle, it's supposed to be there).
I don't think I have a problem with my Canvas settings (I make it so it's always facing the camera) but I don't see where else it could go wrong...
Thanks in advance for your answers !
Game Objects
Scene View
Correct UI
Wrong UI
Canvas Settings
The main reason for this is that the target exists in the world, while the slider exists on the canvas. Those two elements have different coordinate systems, and if you want the center of the Circle+Slider to be at the center of the Sphere, you have to project one set of coordinates to another one (World to Screen).
This can be done using the WorldToScreenPoint method on Camera.
Basically, the UI elements (existing on Canvas) will have to check the transform.position of the sphere in the world in Update function, and set their position using _mainCamera.WorldToScreenPoint(sphereTransform.position)
In my 2d Unity project, I have a Canvas with an Image that I want for a Background.
I have 2 gameObjects in front of this background. But no matter how much fiddling I do with Pos Z, Sorting Layers, or hierarchy sorting, the image is always in front of the objects.
Gif above shows in 3d mode that even though the image is clearly behind these objects, it will always appear over them if they overlap.
Hierarchy:
Main
Camera (Inspector: https://i.imgur.com/Q5a52cf.png)
BackgroundCanvas (Inspector: https://i.imgur.com/m9Pxr6B.png)
BackgroundImage (Inspector: https://i.imgur.com/jTx7pEW.png)
Object1 (Inspector: https://i.imgur.com/YcClEhk.png)
Object2
Any advice to rescue me from this madness is much appreciated.
Set the sprite renderer's transform z value to 0 instead of 100
If that does not solve, please specify camera properties also, so I can try to recreate the exact setup.
Try clicking on Layers -> edit layers, inside sorting layers you can change the order grabbing layer, everything upper appears behind in the camera.
You could create a layer called Object
Assign it to the game objects.
Create an object camera
culling mask -> object layer
depth bigger than you current main camera.
Set it to Projection -> Orthographic
Clear flags -> solid colors.
canvas Render Mode -> Screen Space - Camera and assign the Render Camera to be the Object Camera
Inspector tab of the object or background.
Sprite Renderer.
Additional Settings.
Sorting Layer.
change it to a different layer.
Had this same issue and was able to fix it with these steps:
In canvas settings change Screen Space Overlay to Screen Space Camera
Set the camera variable to the one you are using for your scene.
I figured out a workaround. I basically created a VisualElement inside the UI Builder and set a render texture to the background. Then I added an extra camera to my project to view all the sprites that needed to be on top. That camera feeds the render texture, so now everything that camera sees is forced to be on top of the UI Document as the background of that VisualElement. If you want control over the whole screen, just set the VisualElement position to absolute and max out its dimensions. If your game doesn't have a fixed aspect ratio it might cause some stretching, but other than that I cant really tell the difference. Sorting layers for the UI Documents are broken and unity needs to work on that. This is the best option I've found. Hope this helps.
I had the same problem and I fixed it by attaching the camera to the canvas which is screen space and finally changing the sorting layer of my object to -1.
I'm using a modern (Event System) UI approach in Unity. I have a screen space Canvas, some interactable world space elements, and my camera is properly set up with a Physics Raycaster. I want some of my screen space Canvas elements to let rays through and hit the world space elements.
I set the Event Mask on the Physics Raycaster to just the UI layer, and the elements I want to ignore are on another layer, but that doesn't seem to do anything.
Here's a picture:
The panel itself and the labels on top and bottom are set to the Ignore Raycast layer.
I'm using Unity 2017.4 LTS.
Set off the raycast target on the UI elements you want to only be visible but no interaction.
https://docs.unity3d.com/ScriptReference/UI.Graphic-raycastTarget.html
I have a Unity project, where I need to have both - screen space and world space UI elements (It's an AR project so I need to have some buttons in the world space, and others - attached to the screen).
As I understand I shouldn't have more than UI canvas in the scene, so how can I have both Screen and World space UI elements in the same scene?
You can have more than one canvas in Unity scene, just right click on the hierarchy an add 2 canvas, make one world space and other screen space. check the official tutorial here
HI all,
I'm developing a software to control light show ( through DMX protocol ), i use C# and wpf to develop my main software (.net 4.0)
To help people preview their show, i would like to make a live 3D visualizer...
First, i thought that i could use wpf 3D to make the visualizer, but i need to work with light ..
My main application should send property ( beam angle, orientation (X,Y), position(X,Y), Brush ( color,shape,effect)) to the 3D visualizer
But i would like to be able to move light (position in the scene) by mouse during execution and had value in return...
So ..
Does XNA is the easiest way to doing that ?
Can you help me for that :
Generating light (orientation , bitmap like filter in front of light )
Dynamically moving object with mouse and get position in return
Dynamically add or remove fixture
All of your advice, sample, example are very welcome ... I don't espect to have a perfect result at the first time but i need to understand the main concepts for doing that
Thank You !!
XNA does not contain any functionality for managing a "scene" - you will have to implement that yourself. For example: you might make a Light class containing the information about your light (position, orientation, etc), and then have a List<Light> of them, which you update and render yourself.
I will now assume that you have a 3D model of a "Light" (as in: the metal box containing the lightbulb) and also a 3D model of a stage. And that you can figure out how to render them - there are plenty of tutorials online for simple model rendering in XNA. Here is a starting point.
So your 3rd requirement ("Dynamically add or remove fixture") should be fairly simple once you can render things. Just add and remove Lights from your List of them based on user input. See the Input namespace.
And your 2nd requirement ("Dynamically moving object with mouse and get position in return") should also be simple. If you want your user to move lights by clicking and dragging, just keep track of the mouse position between frames and apply that as an adjustment to the clicked Light's position (or rotation).
To figure out which Light the user clicks in the first place, a good starting point is the Picking Sample.
I am assuming here that the user will click the Light (metal box) itself to move/rotate it. If you would rather have the user click and drag the endpoint of the light (the spot it projects) - that is more difficult. One idea that comes to mind: Intersect a ray from your Light with the stage to find the centre of the projected spot. At that point draw a dummy "handle" object (like a sphere) that the user can click and drag around. When the user finishes dragging, figure out the new orientation for the Light to make that the new centre.
Finally your 1st requirement ("Generating light (orientation , bitmap like filter in front of light )") is the tricky one. My understanding of this is that you want a way to draw the endpoint of the beam of light on your stage model? If so, what you are looking for is called Projective Texture Mapping. Presumably you will have a circular texture for basic lights, and perhaps other textures for gobos.
The quick-and-dirty way to do this would be to draw your stage model, once for each light, with additive blending (so that each light added with the other lights and the black had no effect), with a colour set to whatever you want the light colour to be, and with a black and white texture (a white circle on black background) drawn with TextureAddressMode.Clamp, with a shader that draws the texture with projective texture mapping which is set up with the light as the projection point.