 I just want to give a heads up that this is a re-upload from the original 1.2 video that has now been privated. Now I made a mistake later on in the video, so if you've already seen this video in the past, you can just move on. However, for the rest of you, make sure you stick around. In episode 1.2, you will understand what public and private means, which are access modifiers. And you also know when they are used. Hello guys, it is CryptoGround here. Welcome back to another Unity Idolgate tutorial video. This is episode 1.2. This is the 2021 edition. If you guys learned something new, 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 get on with it. So today, we're going to be using the controller and our data script that we created in the previous episode. So you probably have noticed that I've been using public for pretty much everything. Our classes, our variables are in our methods here. What does that actually mean? What are the differences? First off, if you want a detailed explanation, you should check out my, you should check out my access modifiers crash course. Links will be in the description below. However, but basically what public means is that you can access any of these variables in any class. That's pretty much what it means. Now, if we made this private, then that means we can't really access it. And it's only limited to this class here. It goes the same thing with classes as well. You can't access another class within a namespace, which is like something that goes beyond classes, which I also have a video on that as well. And the same thing for methods as well. So if you made, so if you made this private void start method, then you cannot call this method anywhere else except for in here. And yes, this will also be called by mono behavior. So it'll work just fine. So let's make our flash variable private. So if we'd made this private, we would see some errors here. None in data, but in our controller here for us, we would get an error saying that we cannot access a private field flash here. Basically, we cannot access a private variable in here. That's pretty much when you know you need to make this a public. Okay. If you need to access a variable in other scripts, then you need to make it public. However, if you were to make this text private here, this flash test here, you can make this private here. But now the issue is that Unity won't be able to access this here. One solution to this is by adding an attribute called serialized field. So it's private. You cannot access it in other scripts, but you can also assign it in Unity still. So if we go back to Unity here and check out our scripts here, you can see that we could still access our texts here. However, if we were to get rid of this serialized field here, as this is still private, it should disappear. Yep, there it goes. That's gone. So now if we made this public here, you could see that it's still defined. It's just that we can now see it. So you can either leave it as public or if you don't want to access it in other scripts, we can leave it as serialized field and make this private a private text. Okay. So that's your choice. Either one of these works, but it's it's your again, it's your choice. Now the same thing here with data. We can make this a serialized field and a private. However, since this is a controller script here, we're going to most likely be accessing data in different scripts. So we want to leave this as public. So for methods now, we can't just do serialized field here and we can make this private. So in our case, we don't want it. We don't want to call start or update any other script. It doesn't really make any sense. So we're going to make these two privates and now generate flash must be public. However, if we do private, so currently we have our on click set to generate flash. Okay. So if we take a look at this drop down here, you could see generate flash is in this list. So if we make this a private method, not only queen, not accessed as in any other script, but also we cannot reselect it. So right now it's still selected because it's the same thing as making a text private. It will still, it will remain there. However, once you bring it back, you'll be able to actually see it there. But if it's private, you can't change it. It's hidden, but it's still there. So now the same thing for generate flash here. If we go to the drop down, you can see it's not there. So now if we just select another run a method, you can't go back to it. So we're going to keep generate flash as public. So then we can have our generate flash selected in our increment button. You can either just keep it all public just to keep it simple. But if you want to just keep things minimal and don't want to have other things access certain methods or variables, you can mess with these settings and just make sure you keep an eye on it. Honestly, so I know those are really short episode, but I hope you guys learned something new and I hope it was really helpful and if it made sense and I really hope it made sense as well. Be sure to smash that like button, subscribe to my channel if you're new and turn on the bell for future notifications of videos and live streams. Anyways, I hope you guys have a great day night. I'll catch you guys in the next video, which will be episode 1.3 and we will be explaining all the different types of variables that we can use. Anyways, catch you guys in the next one. Peace.