Godot @export - Everything You Need to Know

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is everything you need to know about at export in godo and when I say export you might be thinking exporting your game but that's not what we're talking about here we're talking about GD script when you have a variable in GD script you can add the at export annotation in front of it to make it editable from the inspector and you can see how insanely useful this is and you might be thinking of course I know at export that's the basics of JD script and you're right but there's so many hidden options at export gives you that if you didn't know about these you would be shooting yourself in the foot while you're creating your game in godo let me tell you everything you need to know about at export the most basic export is this where you specify the type of the exported variable after the colum in this case it's an integer if you omit the type you have to initialize the value then godo will infer or figure out the type on its own you can use other types which will change how the inspector feel behaves you can also use float Boolean and [Music] string and if you expect a longer string and this one field just one do you can use at export multi-line to create a bigger text box you can also export nodes but it helps to be more specific you can specify any node type and limit the field to accept only those nodes or those that inherit from the type you can export resources but this gets you a huge unwieldy drop- down list of possible values it's better to limit the value to a specific resource type now only this resource and ones that inherit from it can be selected you can limit the input to a range of values just use at export range and in parenthesis put the minimum and maximum value then you get a slider in the inspector and you can do that for integers as well by explicitly typing the variable as an INT if you don't need the slider to be crazy precise you can add a step as the third parameter you can put or greater and or less Flags to allow typing in values outside of the range while still keeping the slider confined to the range you can initialize arrays to have godau infer their types or specify the type in which case you are not required to give it an initial value either by just declaring it to be an array or making it a typed array however if an array isn't initialized it's default value is going to be null so it's always better to initialize it to an empty array rather than leave it null to avoid unexpected errors if you use an array of resources you can drag and drop valid resources into it very useful you can create an inum in code and use it as the type of the exported variable the values will be stored as integers starting at zero by default you can also Define an enum within the export like this now you don't get the default value like before but you can specify one by initializing the variable to the index of the item you want to be default if your variable's type is string the inline inum value will be stored as a string rather than an integer and then you initialize it by writing the item as a string both files and directories are exported by pet using at export file you can export any file but it's better to limit the type of file you're looking for by specifying the extension in parenthesis in this case I'm only looking for PNG files you can export a pad to a directory with at export there you can use at export group with any name you want now your fields are hidden under an Expendable dropdown you can optionally add a second parameter next to the group's name this will automatically group up only the properties with this prefix you can add a subgroup within a group with at export subgroup [Music] you can also use at export category but this sort of brakes G those default dividing of properties based on classes they come from so it's not [Music] recommended for string variables only you can use at export placeholder to make a placeholder if you type the exported VAR as color you get a Color Picker in the inspector and you can use at export color no Alpha to allow only solid colors you can export integers and use them as bit Flags to store multiple true false values do it with at export flags and then you need to specify the names of the flags in the parenthesis each one will have a value that is an exponent of two going from 1 2 4 8 16 Etc and that about covers most of what you're ever going to need if you want to see a real life example of using at exports and learn how to create awesome guns along the way click on the video on screen thank you for watching
Info
Channel: DashNothing
Views: 16,335
Rating: undefined out of 5
Keywords: @export
Id: VOcN6Y8mTEE
Channel Id: undefined
Length: 6min 22sec (382 seconds)
Published: Fri May 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.