When I use One Camera to show the scene and put to a TargetTexture,another camera to show the RenderTexture and ui,but I find that the gizmo I use to debug not show.
perhaps the image is misleading, but I have the exact same problem so I'll explain how I understand OP's question:
OP draws a gizmo (not talking about the camera gizmo, but using Gizmo.Drawx in the OnDrawGizmo method) to help him visualize some stuff.
But when he uses a second camera, the gizmo is no longer drawn in the game view (still in the scene view, as you can see on the picture).
I have the same issue with a different setup though, so I'd love to know if OP has found an answer to his problem.
Related
Unity 2021.3.16f1/URP 12.1.8
I've just started with Unity a few weeks ago and am still getting to grips with how everything works. So please don't assume I know everything there is to know about Unity. Treat me as a n00b. 😉
I'm building a VR game for the Quest/Quest2. I have a scene with a keypad on a wall. When the payer "clicks" it, I want the scene to go dark, and a large version of the (3D) keypad to appear with which he can then interact (enter numbers). This keypad must always stay in the middle of his view.
What I did was create a canvas, and added a black plane with 50% transparency and the large version of the keypad. I've set up the canvas as follows:
This works somewhat. It has two major disadvantages: 1) the keypad is receiving lighting from the scene while I want it to be fully lit all the time, and 2) the canvas and all its children clip through walls and objects while I always want it to be rendered in front of everything else (yes I know this will mess with your depth perception in VR, but I already have a solution for that).
So the next thing I tried, was stacking cameras. I created a second camera and set is as an overlay camera. I also set its Culling Mask to UI:
Additionally, I added the new camera to my Main Camera as a stacked camera. I changed the Culling Mask of the Main Camera to everything but UI:
This works they way I want it but at a cost: performance takes a huge hit. My frame rate actually halved. I read everywhere that this is a known problem for mobile devices (which the Quest really is).
Another solution I read about, is using RenderObjects. But I can't really find how to use this. I'm not even sure it really is a solution to what I'm trying to achieve.
So can anyone tell me how I should go about doing this? Thanks in advance!
The solution of lighting is the that you can setup the layer of your keyboard to something like "Keyboard"
And in Directional Light you can uncheck keyboard layer.
The solution of second problem is that you can change culling mask of camera on Run Time Like this:
~(1 << LayerMask.NameToLayer("Keyboard"))
renders everything except the transparent layer.
1 << LayerMask.NameToLayer("Keyboard")
renders only the transparent layer.
NOTE: You can set your own layer and check/uncheck what you want it is just a example
This issue only affects the Scene view, and it is not present in the Game view or when it is running.
Basically my map looks like this.
https://i.imgur.com/BBrKA5f.png
Zoomed Out
https://i.imgur.com/G8BuG8d.png
As you can see there are horizontal lines everywhere. The grid is turned off. They are mostly blue because underneath the grass tile on the sheet is the water tile. You can see under the left of the rock there is a yellowish line, this is because there is a sandy tile below it. The individual images from the Sprite editor look fine. No lines in them. As mentioned, this is only present in the scene view and doesn't affect the game so its not major. I would really like to see if this is possible to fix though as it is quite a pain to look at and design maps with. This issue is present on my PC, and both laptops so I don't think it's hardware related.
Tile palette images:
https://i.imgur.com/huNDlHy.png
https://i.imgur.com/uLwUpUM.png
I've tried adding them to an Atlas, checked for Point (no filter) and no compression. I'm at a loss. No one seems to know how to fix the issue and all my googling points me to bleed or tears in the actual game which is not the issue I am having.
Any help would be greatly appreciated and I will provide any additional information that is needed.
Thank you.
So after a few days of frustration and help from the Unity discord, I finally found an answer.
It turns out you want to disable Pixel Snap in your Shader component on your tilemap object. As soon as I did that all the lines in Scene View were gone.
Setting to change:
I need a solution for my problem, please.
I make a character in unity 3d base on AR, the problem is when I build the project in my android phone I can found the character or I should to turn a camera for search where is he.
I need to make this object into the center of my camera how can I do this, please ...
The question isn't the clearest, but I suggest attaching the camera to the gameobject you want to see in the editor.
This link is to a unity tutorial.
https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera
Just re-read your question, AR skimed over that at first ... so you dont want to move the camera rather you want to move the object.
To find the middle of the screen in world space is what you asking for.
Camera.current.ViewportToWorldPoint(new Vector3(0.5f,0.5f, 100));
Use your camera to find a point in the world that is in the middle of your view. You have several options, ViewportToWorldPoint for example as shown above. ViewPort calls 0.5,0.5 the middle of the screen, Z is the distance from the Camera origin point.
You could alternativly cast a ray from your camera center screen and find a point on the ground to put your character at ... would need to know more about your wourld set up to help further.
My old answer is how to move a camera ... I will leave it case its useful to you.
[Edit Old Answer]
The other answer will work and is nice and light but has its limitations as your project advances.
I recomend Cinemachine for camera work, in this case a simple Cinemachine virtual camera setting its 'Look At' and optionaly its 'Follow' is what you want.
https://unity3d.com/learn/tutorials/topics/animation/using-cinemachine-getting-started
Cinemachine tutorail above. in short, Cinemachine works with the concept of 'virtual cameras' these are just light easy to use behvaiours that discribe how to 'frame' a shot e.g. what to look at, how to move, etc.
You real camera will get a Cinemachine 'brain' which simply listens to these virtual cameras and sorts out what to do to the real camera to make it happen. Getting to terms with this system will greatly improve your camera work and masivly simplify it.
Things like simply attaching the camera to the player object and similar work but have big limitations that end up biting you in the backside eventually.
Alternativly you can write a script to transform the camera based on your own custom logic the draw back here is the 'ball of code' problem ... that is at first the logic is simple but as you want more and more specific shots framed up it gets to being a spegettie monster quickly.
My title might have actually been a bit misworded, as to be honest I'm not sure how to word it, but basically I'm making a game on Unity and I have my main scene and I am making a main menu however what I want to do is have a, I guess, camera slowly panning around the main scene as the background of the main menu. Not sure if I worded that right or what wording to actually type into Google to research it so I'm hoping you guys might be able to point me in the right direction.
Cheers guys,
Jason
As stromdotcom mentioned you can attach a script to the camera.
It's hard to tell what you're trying to do but if you want to circle the camera around a point...
Try making an empty game object in the middle of your scene and point the camera at it.
Make the object the parent of the camera (using the object and cameras transform properties).
From here you should be able to set the game object to rotate using a script, which should make the camera spin as it is a child of the object.
I have not tried this in Unity but I have used this technique in other programs so I'm assuming it will work. Sorry if it doesn't.
If your scene is already set up then you can attach a script to your camera which simply modifies the camera's transform to move it around the room. You can move and rotate the camera just like any other transform in your scene.
Im pretty sure what you are looking for is "Animation view". Unity has a tutorial on it: https://unity3d.com/learn/tutorials/topics/animation/animation-view?playlist=17099
So I have a small problem with my camera in 2D view. I have a background sprite that serves just as it sounds, the background. My problem is, I need the camera view to take up the entire background. At the moment I can only get the camera to capture out to the sides of the background but it will not fully catch the top and bottoms of the background.
This poses a problem, it will cause me to have to make all of my following items in the project to be super short and fat.
Yes, I know this is probably a stupid issue on my part or an easy fix, but being new to Unity, I am unaware of how to deal with this problem.
Here is a snip of my issue http://imgur.com/pz1sg9B
As you can see, I cannot get the camera to reach the top and bottom of the background thus leaving me with super short and fat items.
Thank you in advance!
You have to change the Viewport Rect on the editor.
You can check out Unity3D Manual for more knowledge on Cameras in Unity3D.