I am working on a 2D project and I want to zoom in my map by scrollwheel. I am sure that my code is working (because during the play mode, field of view changes when scrollwheel is rotated) but no change on the screen is observed.
Besides, during play mode even if I change the field of view manually (from the editor), the screen view remains same. That is, although field of view is observed to be seen changing but the screen view is not.
What are the possible reasons for that?
Here is the screenshot of the editor attached:
Possibly because you're using screen space canvas. Put the canvas in the world space for field of view to have any effect.
Related
I have created a simple Unity AR Foundation app which places objects on a plane whenever the screen is touched. I would like to add some UI so the user can press a button rather than anywhere on the screen.
I have followed several different tutorials which seem to be doing mostly the same thing. I right-click the Hierarchy -> UI -> Button. I have scaled it so it should fit my mobile screen and anchored it to the center so it should be easy enough to find.
These are the canvas settings:
Might the UI somehow be hidden behind the camera feed from the AR Session Origin -> AR Camera? Am I missing any steps to anchor the UI to the screen?
As you can probably tell, I am very new to Unity but I feel like I have followed the tutorials for creating a UI, but it simply won't show. If you need more information, please just ask and I will provide.
Not sure but sounds like you might need to have that Canvas Scalar to scale with the screen size. Change the UI scale mode to Scale with Screen Size.
I was compiling the wrong scene. I had two very similar scenes, so when I compiled I didn't realize there were no changes and that I was inspecting the entirely wrong scene.
Once I changed to the correct scene the setup above worked as expected.
Here is my issue, the way my game works is that you click on the edges of the screen to navigate. This is done through an Overlay Canvas using OnPointerClick. I colored the navigation areas, and scale the canvas according to screen size and the navigation areas appear on their screen as they should. Yet they CANNOT click any of the elements for some reason. They have another monitor that works without issue. They've noted that their larger monitor is AMD. I've also confirmed that the ability to navigate in game has not been hindered. I have never had this issue (or any other testers) on 1920x1080 monitors.
I have completely exhausted what the issue can be, they cannot even navigate on a bare bones tutorial. Any ideas would be GREATLY appreciated.
Here is an image of their screen and the respective clickable navigation areas.
[img]https://i.imgur.com/NVQkA8g.png[/img]
Unity 2019.2.14f1
Put a Image component without sprite, because without that, you will not detect any click. You can set the alpha to 0 after you see that working.
Also check the anchors of the navigation areas.
I'm quite new to Unity, so I'm sorry if this is a basic question. I've been trying to set up the UI for a mobile game, but I'm not quite sure how to make the UI lock it's position, no matter the screen size. I've tried using anchors (though I don't fully understand how to use them properly), I've tried using a canvas scaler, I've looked at the Unity document and I just can't seem to find an answer. The buttons are off screen/half off the screen when I build the game to my device/switch screen sizes in the game view. Does anyone know how to fix this?
You can set your anchor point by selecting the UI object (such as a button) and then clicking here and selecting the right anchor point. You can also press down shift to set the pivot and/or alt to move the object to that point at the same time. The object should now be anchored to that point and keep its position even if the resolution is changed. You can set a precise position from the inspector, too. Simply adjust the Pos X and Pos Y variables. It will still adhere to the anchor point.
Note that you might have to play around with the Canvas object's UI Scale mode and its settings to get the right setup.
I am working on a networking game where a roomListItem shows all the available gamerooms online. for every gameroom a button gets instantiated inside the roomListItem and this happens as intended, the problem is that the button that gets instentiated is invisible, i can resize it but still can't see it.
i already tried moving the button at the bottom of the hierarchy but it's still not visible.
The problem is that you are masking all the content, there is an object named Viewport that contains a mask component, this component causes that all UI elements below it will be masked, you can try:
Remove it.
Change the sprite for another one if you like to mask it in some way.
GIF here: https://share.getcloudapp.com/YEu8JPXN
I have a UI Scroll View in Unity showing a list of Toggles that I dynamically populate. My problem is that when I instanciate a new element in this list, it is in the inspector but it is not rendered on the screen ?
This happens also when i manually add a ListElement GameObject to the content element of the list.
What is very weird is that if I move the window so that the screen size changes, it is drawn... Cf. the two screen shots.
On the first screen shot, I added a ListElement prefab, like you can see, it is not drawn but it is there and active.
Then I resized the Editor Window and it magically pops up... This happens also on a build of the game (on Android for example, it is drawn when screen orientation changes but not before...).
I tried to Force canvas redraw, LayoutForceRebuild but it doesn't work. The fact is that i have no idea why this is happening...
Screen shot 1 :
Screen shot 2 : the red arrow shows what I did to make it drawn
Screen shot 3 : with Show mask enabled on the view port
Screen shot 4 : same as 3 but after resize
I met with this problem too and finally solved it, dunno whether it's a same situation.
I find the window or UI Elements repaints only when refered variables are changed. So when it comes to the ListView, it is not called "OnValueChanged" if you add elements to [ListView.itemsSource]. The solution is to new a list and assign to [ListView.itemsSource].