Gaze Over, display Tooltip in Unity with GoogleVR - c#

Does any know or can possibly point me to some instructions or a github repository on how I can create a script where I have an object and in GoogleVr (Cardboard) if I was to gaze over an object, a tooltip would appear?
If anyone is familiar, in the Cardboard Demos under Under Arctic Journey > Learn, when you click on the fox, a tooltip appears to showcase that item along with like a brief description on it. I want to have something similar (maybe even the same thing) except just having a gaze over will automatically show it. Is this possible?
I want to have this done on multiple objects in my project so I want it created so I can easily substitute out text and whatnot.

Have a script with a reference to a World Space Canvas (WSC). The WSC will be your tooltip and be activated when you hover over the object and disabled when you don't.
You can set images and texts of the WSC through the inspector or through code if you make a reference to them.
The script should also always have its rotation set to face the player.
You can use the SetActive(bool) method to show or hide the WSC.
The UI system makes it easy to create UI that is positioned in the world among other 2D or 3D objects in the Scene.
Start by creating a UI element (such as an Image) if you don’t already have one in your scene by using GameObject > UI > Image. This will also create a Canvas for you.
Set the Canvas to World Space
Select your Canvas and change the Render Mode to World Space.
Now your Canvas is already positioned in the World and can be seen by all cameras if they are pointed at it, but it is probably huge compared to other objects in your Scene. We’ll get back to that.
https://docs.unity3d.com/Manual/HOWTO-UIWorldSpace.html

Related

Is there any way to render an object while standing in it?

I have a first person controller and currently if I walk into a slightly transparent object, it disappears until I walk out of it.
I have a 'water' cube object that is very light blue and transparent, and when I move my camera into third person view then enter the water, my screen turns light blue which is good. In first person mode (which is what I'm trying to figure out), the cube disappears and my screen color remains the same.
I know it has something to do with my camera but even after going through all the features on unity docs and changing a few settings in the inspector, it all remains the same.
Like mentioned in the comments your cube is not visible because the backside of its faces is being culled, meaning they are not rendered. This is not a camera setting but a property of the shader your water cubes material is using.
You could create get a duplicate of the shader your are using where you add Cull Off to change this.
Read about it here.
If you want to go that route you need the source files for your shader. Assuming it is one of the Unity Built in shaders you can get them from the Unity Download archive here for your Unity version.
Clipping the camera trough objects is rarely a desired and you should look at a different way of achieving your effect like using a post-processing volume because the "water" would still be a cube and be drawn behind everything in front of its faces.
For example in a FPS type game this would result in the gun not changing color.

Im trying to create a menu scene but when i render it, it is kinda dark. How to fix the dark lightning

As you can see in my Unity scene
it looks dark.
game tab
you can see here that it's dark.
I've done going to window > render > lightning > clear baked data but its still the same.
Any unity devs can help me, thanks
As you can see in my lightning tab
auto generate is disabled so I can't check it to verify if it can solve my problem.
Somewhere in the Canvas you have an object that has a sprite on it where the color is modified. Also check the alpha setting for the colors there.
Lighting doesn't affect UI elements like that. That only applies to non UIElements like 3D and 2D objects placed in the world (https://docs.unity3d.com/Manual/LightingInUnity.html).
So it's just a sprite that is causing this background color as #Çağatay IŞIK suggested.

Screen Space Ambient Occlusion (SSAO) being rendered for clipped meshes

I am working on a small game where I only want to draw the objects (mesh) when it is inside an invicible box. I have gotten the clipping to work so that the mesh is only rendered inside the box (using the solution mentioned here: https://answers.unity.com/questions/1875660/urp-render-only-whats-inside-a-cube.html
The only annoyance now is that even when the mesh is clipped, the SSAO is still being rendered as you can see in the following image (in the red box):
I assume it is because the object is still contributing to the depth normals - but I am unable to find more information about this - or even if this is the actual issue.
Do any of you have a suggestion for how to prevent this from happening?
I am using Unity 2021.2.8f and URP v12.1.3 btw
The Postprocessing effect SSAO is applied to all layers seen (not culled) by your main camera. Try to put the object on a different layer and ignore it on your main camera.
You could also integrate an additional forward renderer (+ new camera) to your project, which does not use the SSAO effect and takes care of your object.

Sprites drawing over text in unity

I am trying to display the score for my game, however, my background sprite is drawing right over it. I have tried assigning some type of layer tag but I can't find one for text. Everything I try, the text is always hidden under the sprite for my background (and any other sprite for that matter). Is there a way to assign the text to be drawn over everything, I have tried looking at tons of sites in hopes of a fix but I can't seem to find anything. Any help is extremely appreciated.
From the hierarchy creation menu, pick UI->Text
This will add you 3 Elements to the hierarchy: Canvas, and 2 child gameobjects which are Text and EventManager. These are all needed for the proccess.
The text gameobject is part of the UI system Unity has, means that if done correctly, it should show over all sprites.
Programmatically you can change text by simply saying:
myUItext.text = "Text that will show on UI!"
Manually you can change position, font and text using the hierarchy view.
For further details use this video from the official Unity tutorial

VR score text display

I am trying to make a VR game with google cardboard in unity. However we can not find a way to display score text right in front of the player. However when I add 2D text it is only on one side and therefore on one side of the eye and getting the position right for 2 texts is hard. If I use 3D text and set in front of the players position I think it will go into the wall if a player hits one. Is their any way to display a score on google cardboard / Unity VR.
You can either use native Unity Canvas UI or Googles hack to render OnGUI calls onto a texture.
I would definately recommend Canvas as that is the way Unity is working on their UI features, and it has much better layout capability.
To use canvas, Right click in the hierarchy and add UI->Text. You will automatically get a canvas. The important part is set the canvas to world-space (not screen space overlay). Then drag the canvas game object so it is a child of the Google Cardboard Main head object. Scale it down (like x:0.001,y:0.001,z=0.001) because by default it will be massive. To avoid going through walls position it about 0.5m in front of the camera - within any collider you may have.
there is another approach as well which you can place that canvas under camera make it world space, and then adjust it as you want, after that where ever you look at it will be seen easily ( as suggested by earlier user in answers) as you can see below in picture i placed canvas > Text > under camera which i used for oculus/ google camera

Categories