 In this episode, you'll be learning how to use anchors in Unity. Hello guys, it is Crypto Grounds here. Welcome back to episode 1.6 of the Unity Adelgate tutorial series. This is the 2021 edition and today we're going to be learning about anchors. If you enjoyed this video, make sure you smash the like button, subscribe to my channel if you're new, and turn on the bell for future notifications of videos and live streams. Anyways, let's jump right into it. So as you guys have seen a little bit at the beginning of the series, I have used anchors just a little bit just to get things working. So anchors is this little section right here. This is where you can anchor certain objects to a certain side of a parent object. So for example, a text inside of a button, this is a stretch anchor. So basically it's stretching to all four sides of this increment button here and changing the anchor changes the values here as well. So if we change this to stretch, it'll basically change it to number of pixels away from each side. So if we change this to all 10s right here, basically what this means is that it is 10 pixels away from each side of the increment button. Now if we did zero left, zero right, and just kept the 10 for top and bottom, basically it's zero away from the left and right sides of this increment button and 10 pixels away from the top and bottom. So that's basically a stretch anchor. You're going to be using this a lot. And this is very useful when it comes to making backgrounds. Speaking of backgrounds, let's actually make one real quick. So we're going to be adding a UI image. And we're just going to call this the background. And so basically what we're going to do is we can either stretch this to the canvas here, or we can type in the numbers here, like this. So we go to the anchor section here, click on that to stretch on both sides like that, and just type in zero for everything. And now it becomes the background. I'm going to hide this image real quick, because I want to grab this background color here by clicking this color picker here. And there you go, turning on the image. And now we can move this background to the behind everything like that. So you obviously can't tell the difference, but if you were to change this color, you would know that this is indeed the background. Obviously change this picture to whatever you want, you can have a custom background picture if you'd like. So now as a reference, if we were to change this background color here, we could change the canvas size or the resolution size and it will stretch with the canvas. Now, if we actually got rid of the stretch right here and kept it at anchor to the center, which is right here, then it will do something like this. It'll basically remain its size. And yeah, it'll just look kind of weird. It will overlap or it just won't be big enough. So for their background, we want to keep it at stretch. Okay, so for a button, it's currently anchored to the middle of the screen. So if we go to our portrait resolution here, you can see it's still anchored to the middle. What if I want to anchor this to the bottom? Well, all we can do here is click on this anchor here when we select our increment button and do a center bottom anchor right here. Click that. And now it's anchor to the bottom. So if we go back to our portrait resolution here, you can see it's anchor to the bottom like that. So now there's tons of anchors you can mess around with. This is just the this is just the very basics of them. And if you were to click this right here, and you held down shift, you could basically change the pivots anchor here. Well, now the pivot anchor, you see that little circle right there, this thing right here, this is the pivot anchor right here. So by default, it's always at the center. And that is like what you use to rotate stuff like this. Now, if you move this anchor here, now let's just put it like for example, in the middle of the space like right here, and we were to rotate it, it would rotate around that pivot point like this, which could be useful for some things like creating designs patterns or just rotating stuff in a specific motion or a certain fashion. Now I just like mine in the center. And yeah, so basically when you hold down shift, it sets both the position and the pivot anchor here. Now when you use alt, it automatically moves to the certain anchor. So if you hold down alt, it will go to that certain spot, which could be easy. You can move things very fast. You could stretch like that. You can move stuff around. And yeah, that's basically what it does. However, I like some offset here. So I'm going to set position wide to like negative 50. So like, which basically means 50 pixels away from the top of the screen. And also I want to move this pivot point to the center of this here, because I know I don't need to pivot anywhere else. So I think that's fine. And I'm going to anchor it back at the top like that. So that's basically how anchors work. If you want to check out more on anchors, check out my special video on anchors. The video will be in the description below. If you learned to the new if you enjoy the video, make sure you smash the like button, show some support, consider subscribing to my channel, if you enjoy this content and turn on notifications for future live streams and videos. If you want to support my channel, make sure you click that join button below or check out the Patreon in the description. Anyways, thank you guys for watching. Have a great day and night. I'll catch you guys in the next one. Peace.