‫Hey, welcome back.
‫In the last video, we learned a few new property specifiers that allow us to expose our C++ variables
‫in certain ways to the details panel in the blueprints.
‫In this video, we're going to learn some more specifiers that allow us to have more control over access
‫to those variables.
‫In the details panel, we're also going to talk about how we can allow, read or write access in the
‫actual event graph for a particular C++ variable.
‫So let's dive right in.
‫Okay.
‫So I'm back here in VS code and here are the variables we created in the last video.
‫Now here is my speed variable.
‫This was for the challenge.
‫You probably created a different variable, which is totally fine, so keep that variable there.
‫We're going to do some more things with it in this video.
‫Now we've learned that we can make a variable visible anywhere, and when we say anywhere, we mean
‫on the details panel, either on an instance or on the default blueprint.
‫We saw that we can also make it edit anywhere, and when we use visible instance only, it's only visible
‫on an instance.
‫You can't even see it on the default blueprint and in any case, you can't edit it because it's grayed
‫out.
‫So this allows us to make our variable visible only on the instance.
‫But what if we'd like it to be visible only on the default blueprint?
‫Well, there's a specifiers for that too.
‫Let's make another in 32 and let's call this visible defaults only int.
‫And we can initialize this to a value.
‫I'm going to give it five and we'll give this a U property as well.
‫And the specify are for making this visible only on the defaults.
‫You can probably guess what it is.
‫It's visible defaults only.
‫So I'm going to compile this and back here in the editor, I'm going to open up BP Pond Tank again.
‫And with BP Pond Tank self-selected, all of our variables are up here at the top, so I'm not going
‫to search for it.
‫But here's our visible defaults only int and it's got the value five and of course it's grayed out now
‫as the name suggests, it's visible only on the default.
‫So if I go in the world and select one of the instances of BP pond tank here, there is no visible defaults
‫only int it's not visible on the instance, only on the default.
‫So that makes sense right now.
‫Let's go back into VS code and we have a few more specifiers to learn about.
‫Now we've seen that we can edit anywhere and that with our visible specifiers we can choose instance
‫only or default only.
‫So as you've probably guessed, we can edit on only the instance or only the defaults if we choose.
‫So let's make a couple more in 30 twos.
‫I'm going to make one called edit defaults only int and initialize that to a value say nine and then
‫another int 32 called edit instance only int.
‫And I'll give this a value of 14.
‫So we want edit defaults only int to be editable only on the defaults and edit instance only and to
‫be editable only on the instance.
‫Now the names of these specifiers are pretty consistent, so I'd like you to just guess what the specifiers
‫would be for these two access levels.
‫Go ahead and just do a quick little mini challenge.
‫Pause the video and fill these in, see if you're right.
‫Okay so these are going to be you properties and edit defaults.
‫Only end is going to get you probably guessed it.
‫Edit defaults only and for edit instance only int I'll give this a u property macro and this will be
‫edit instance only.
‫So it's pretty intuitive.
‫Let's go ahead and compile these and back here in the editor with BP -- tank open here's our edit
‫defaults only int we don't see edit instance only and we didn't expect to it's set to nine here we can
‫change it and if we go into the world with one of our instances selected we can see edit instance only
‫int and of course that's editable as well.
‫So we've now added three new specifiers to our graph here.
‫We have visible defaults only, which is in only the default column and in the read only row.
‫And then we have edit defaults only and edit instance only in their respective rows.
‫So we're filling up this graph pretty quickly, but you'll notice that there are a couple of spaces
‫empty over there to the right and the event graph column.
‫So let's talk about these for a minute now.
‫I'm here in BP Pond Tank, and we have all of these variables that we've exposed to the details, panels,
‫depending on their specifiers.
‫You can see them here or on an instance.
‫But what if I right click here in the event graph?
‫The event graph is another place where we can access variables and potentially change them.
‫So if I type edit anywhere, I do not see the edit anywhere.
‫INT it's not exposed to the event graph.
‫We don't have access to that.
‫There is another specifiers that allows us to expose things here in the event graph and that can work
‫in conjunction with the specifiers that control the details panel accessibility.
‫And I'd like to expose one of these variables to the event graph.
‫Now, I could choose any one of these, but I'm going to choose this visible anywhere.
‫INT Now the U.
‫Property macro can take multiple inputs, so we have visible anywhere.
‫We can still have that.
‫I'm going to place a comma and I'd like to add another specified to that will give this visible anywhere
‫end exposure to the event graph.
‫So what I'm going to use is blueprint read, write, blueprint read.
‫Write has to do with the event graph.
‫It has nothing to do with control over the details panel.
‫That's what this visible anywhere is for.
‫So Blueprint Rewrite does, as the name suggests, read access and write access.
‫So let's see how that looks.
‫Let's compile this and I'm back here in the editor in the event graph if I right click and type visible
‫anywhere.
‫We'll see two different options get visible anywhere int and set visible anywhere.
‫INT If you select, get visible anywhere.
‫INT We get a node and this is just like any other blueprint node, it represents that C++ variable and
‫if we drag off of this, we can access that value to do something with it.
‫Now I'm going to scroll out and you'll see that we have these grayed out nodes actor begin, overlap
‫and event tick and Begin Play is called at the beginning of the game as you know.
‫So we can do something here.
‫I'd like to use a print string node and if I drag off and type print string, then here it is.
‫It's a blueprint function node and it takes a input called in string.
‫Now if I hover over it, it says in string and then string right below that.
‫That's the type that this node accepts as an input parameter.
‫And we know that our visible anywhere int is an int 32, not a string.
‫But if you click from the output of this note and drag and stick it right here in the input before you
‫release the left mouse button, you see a pop up that says convert integer to string and if you release
‫then you get this handy conversion node that converts from an integer to the string type, which is
‫very handy for us because we don't have to figure out how to convert an integer to a string.
‫It's just automatic for us.
‫Now, if I hit play, we'll see the value 12 printed three times and it only lasts for a few seconds.
‫That's the behavior of print string.
‫Now, the reason we see it three times is because I have three different instances of BP pond tank here
‫in the world.
‫Depending on how many you've dragged into the world, you'll see that many.
‫Because for each of these individual instances, begin play is getting called at the beginning of the
‫game.
‫So just to avoid confusion, I'm going to just delete my other two and just leave a single instance
‫of Beep Pond Tank here in the world.
‫So I have only one and if I go and hit play again then I see 12 printed to the screen only once.
‫So that is read access to visible anywhere int but we saw that we also have write access.
‫That means we can set its value from here in the event graph.
‫So if I right click and type visible anywhere int again then I can select set visible anywhere int and
‫I have a setter node which takes an input we can pass in the value from some other node or we can take
‫this little text box and hard code of value, say 66.
‫And now as soon as the flow of execution from begin play reaches this node, then the setter node is
‫going to write to visible anywhere and it's going to set its value to 66.
‫And of course we can print this out again.
‫So I'm going to use print string.
‫And for the value passed into print string, I'd like the value of visible anywhere int.
‫Now I can do this one of two ways.
‫The setter has a return node, so after it set the value, then it returns that value and we can use
‫it so we can plug it straight in to print string.
‫The other way is to simply right click and get visible anywhere int use that get node and we can hook
‫up the value from this node right into print string that would do the exact same thing.
‫So I don't need that.
‫I'm going to delete that node.
‫And now what I'm expecting to see when I play the game is to first print out the value of visible anywhere
‫int, which starts off at 12 and then after setting its value to 66, I should see the value 66 print
‫it out to the screen.
‫So let's hit play and we see 12 and 66.
‫Now they look like they're in reverse order.
‫That's because print string adds newer messages on top.
‫So that is normal behavior.
‫Okay, great.
‫So we've seen that we can make a variable blueprint read right now.
‫We can also control whether or not we can set this from the event graph.
‫So let's expose another variable so that we can get it from blueprints but not set it here's edit anywhere.
‫INT I'm going to add a comma and add a specified to to this now in order to access it in the event graph
‫but not be able to set it or write to it.
‫The specify hour is blueprint read only so edit anywhere int is now blueprint read only.
‫It's still editable in the details panel, both in the default and on instances, but in the event graph
‫it's read only.
‫So let's go ahead and compile this and back here in the editor, I'm going to right click in the event
‫graph and type edit anywhere and check it out.
‫We have get edit anywhere end but we do not have a set edit anywhere int because it's blueprint read
‫only, we cannot write to it.
‫So I'm going to select it.
‫Here's edit anywhere.
‫INT And if I wanted to I could use a print string node to see its value.
‫No need to do that.
‫We already know how to do that.
‫I'm just demonstrating that we cannot write to this variable.
‫Okay, so I'm going to go ahead and highlight these nodes and delete them.
‫So our graph is now filled out.
‫We've learned that we can make our variables visible only on the defaults and we can make them editable
‫only on the defaults or only on the instance.
‫So we really have full control from the C++ side.
‫Now we also saw that we can expose these variables to the event graph and make them read only or read
‫right using these blueprint read only, blueprint read write specifiers.
‫So now you have a challenge.
‫In the last lecture we created a variable.
‫I made a float and called it speed.
‫Now you're going to take that variable.
‫You create it in the last section and control its access in the event graph.
‫So expose it to the event graph using one of the new specifiers you've learned, and then you're going
‫to test out the read write access for this.
‫Use a print string node so that you can see its value and if you change it, prove to yourself that
‫you've changed it.
‫So if you make your variable blueprint read right, try changing it with a set node and then using a
‫print string node to see its value using event begin play.
‫If you made it blueprint read only then you can simply get the value and print its value using print
‫string.
‫So add the correct specify to your custom variable and use print string to test out access in the event
‫graph.
‫Pause the video and give this a try.
‫Okay.
‫So I'm going to scroll down to my speed variable here and my speed variable is edit anywhere and I'd
‫like it to be blueprint read.
‫Right, so I can change it from within the event graph.
‫So I'm going to add blueprint, read, write and simply compile.
‫So back in BP pond tank, if I type speed now I see the getter and setter for this.
‫So I'm going to use set speed.
‫I'm going to set its value from Begin Play.
‫So let's hook this up.
‫And for the value, I'm going to enter 900 and from the set note if I drag off I can type print string.
‫Now I'm going to click and drag off of the output node, hook it up to string.
‫So if I hit play, there's 900, notice it says 900.0.
‫That's because this is a float.
‫And so it's giving me the courtesy of showing that first decimal point.
‫So that's kind of a nice built in feature here.
‫It's showing me one digit to the right of the decimal point for my speed variable.
‫So in summary, we learned some more specifiers for the new property macro.
‫We learned visible defaults only, edit defaults only and edit instance only.
‫And we also learned how we can control read write access in the event graph with Blueprint, read,
‫write and Blueprint Read.
‫Only the C++ programmer has a great deal of control over what gets exposed and what can be changed in
‫the blueprint and where we'll be using these throughout this section of the course.
‫And you'll continue to use them throughout your career as an unreal engine developer.
‫I'll see you in the next lecture.