It’s my very first post on the forum, so my apologies in advance for any rules faux pas. Anyway, as the title suggests, I’m following the following tutorial from Unity Technologies, and have a couple of questions on the discussion board there, all of which seem to have gone unanswered, so I’m seeking answers here instead.
The issue that’s currently blocking my progress regards the setting of a Button’s Y position outside of the Canvas/game screen. Would anyone here be kind enough to go over and take a look at section 9. Restarting the game, and let me know if I’ve missed a trick, or whether it’s actually the tutorial that’s missing some key information?
Yes. I can see the button in the Scene view, however it’s off the canvas.
Enabling Maximise on Play does indeed let me see the button, but it’s still off the canvas, whereas in the image in the tutorial, you can see that the button is still on the canvas. It seems to me that whoever wrote the tutorial extended the canvas in some way to accommodate the button, or that there is a setting for the canvas that allows it to stretch to accommodate all GameObjects, but either way, the tutorial doesn’t seem to include this information.
When you create a UI panel, it stretches to fill the Canvas (as explained in Part 2. Creating the game board).
When you create the second panel (“Board”), and select and set the Anchor Presets, the Rect Transform Width and Height are shown, in the tutorial, as 1346 and 948 respectively, which is the size of the Canvas.
In the Game Window, add a new fixed resolution of 1346x948 and your Canvas will be the same size as that of the tutorial.
Thanks Valjuin. While your solution does indeed make the button visible when I play the game, it still doesn’t look like the image in the tutorial. For reference my image looks like the image I have attached below. Also, I’m not sure that setting a specific aspect ratio is a good solution. I was hoping there might be a more dynamic solution that will work for different aspect ratios.
I agree that you shouldn’t have to set a specific aspect ratio, and the tutorial doesn’t instruct you to do that.
My project looked like yours, except that the background was totally black.
I decided to start a new project and created the Background panel, the Board panel and the Restart button, and set them up as described in the tutorial.
As you can see from the screenshot, the resolution is set to the default Free Aspect and my Canvas looks like the one in the tutorial.
Thanks for your help Valjuin. I’m sorry I took so long to reply, but I decided to spend some time trying to learn through some simple trial and error. In the end, I learned that the best solution for me was to simply choose a single static target resolution, and just position and size everything relative to that. In the long run, I’m not really sure how this will work if I want to target different resolutions, but I think I’ll just cross that bridge when I come to it.