Crash course into Unity Addressables

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
that's cool so i guess for anyone coming in i am the i am the instructor tonight this is the talk on the crash course into addressables and how they're really stupid easy and i will do my best to watch my language and also how to use addressables for content updates i guess you say the moderators on this panel are stephen and david who if they want to watch volunteer to watch the chat if people ask questions i'll let them interrupt me to ask questions otherwise i will not pay attention to any chat whatsoever because i cannot multitask got you do we have a chat related to this yeah youtube i think the twitch chat i think it's going so let's check that about five minutes so we'll get started um how's my audio sound is this good perfect excellente let's see so i know i'm just going to be rambling about dressables and the reason why i know so much about dressables is that my day job required me to learn it so i did and addressables documentation is it's not bad it's certainly not good either metaphorically speaking the dressable documentation is like imagine you went back in time and you found like an ancient roman and he said here's a car like what's a car it's like oh it's like a horseless carriage and he's and they say oh how do i how does it work can you just give them a driver's ed manual so they read that that book and now it's like great they know to not cross the double yellow line they know to turn right on the red red means stock green means go but no point in that book does it actually tell them to take metal key insert into car turn 15 degrees to ignite engine you know that's the problem with the addressables documentation it assumes you already know what you're doing and so it gives you all the advanced stuff so this is a crash portion to like this is how the average person can use addressables and read documentation after this so with that in mind uh stephen and dave i know both you guys say that like you have either you haven't used addressables or you tried to and couldn't figure it out is there anything that like in particular that like you have questions beforehand so i'll keep that in my mind while i go over it what is an addressable excellent definitely cover that one for me it was labels cool definitely i'll go i'll make sure to go over that then so let's see my nervousness is like we're going to do this live and just i hope it all works fine because the one gripe i saw a major gripe i still have with the dressables is that sometimes they'll throw an error message and it's very obtuse it basically just said it broke and it'll give you some like nonsense that doesn't really explain what happened so that's my concern is like oh my god there's something broke live it's like uh [Music] this wasn't supposed to happen no one saw it so yeah so we had a few minutes just pretend we're the only ones watching because i think we are right now i mean you probably are i'm just trying to be polite and the people are going to come back and watch the recording you know here's just some pre-roll so they know to ski they can just skip to the well like insert time marker here mark or actually starts so aside from addressables uh stephen david you guys got any interesting new tech you've been looking into i've been looking into chat bots and ai voice stuff apparently the ai text to speech has gotten really damn good nice i've seen some of that and it looks really cool clicked on the links that david posted and i've just been looking at old tech not interesting hey man old tech is always interesting you know it was like one of the john carmack keynotes he's talking about how to optimize for vr and his suggestion was to look at like the early like almost like launch titles for the original xbox how they had to optimize things to get stuff to work to get like inspiration for like weird tricks and stuff you can find out so i just been falling down that like my youtube cycle so hey old tech is always cool that's good to keep in mind i'll check that out i think the biggest thing is like it's like how little ram they had and even less of it was video ram and that's just that's like a precious resource in commodity it also gives rise to like hilarious speed running glitches like the infamous ocarina of time where it's like you open a door you open a door you like dump a bottle in the ground pick it back up and then the door just warps you to like the final boss just because they only had so much ram the bottle accidentally overwrites the ram location for the door good all right so we'll get this started let's get going all right addressables they're easy they're super easy oh my gosh they're so easy so i have this scene right here this is saying it's got a box in the cube and a campus sign right so i want to hide this i have some stuff pre-set up for later so we got our button here right it's called show me the stuff what's it gonna do well it's going to show me stuff it's going to do it right now right so let's talk about what resources are resources are something that's been since forever like this that's og unity stuff so show me stuff this is pretty much standard resources or how do i zoom in on this i guess i can't zoom anymore uh control plus plus there we go all right we're in we're in old person mode there we go this is this is standard unity resources right here right we have a folder that has a resource in it boom and anything in this folder can now be just loaded from any piece of code anywhere in the game doesn't matter if it's in the scene or not and if you've never used resources before i'm going to back up a step you'll probably know that hey if you want to load something you'd have to like drag and drop prefabs onto your scripts well unity when you compile your game it goes through every object it looks at all the scripts and looks for all the prefabs that's how it knows like hey this scene needs this much data so i gotta load this into the memory when i load a scene cool resources is this exception unity will just always have this on the disk and so now anything via code see i just it's called stuff i put my stuff in here and in code i say resources dot load stuff get it and make it done right this is not addressable this is how it's always been and so now i just hit play show me the stuff boom football horse wrestling card rad right my favorite magic the gathering card or something i don't know that one's missing from my collection well it's it's super rare it's got it's the only card that has nfl sponsorship and it's romansky fighting a horse so very controversial card because i'll football or whatever anyway so that's standard resources right that's that's how like you so you've probably been using it a lot of people say don't use the resources folder the reason for it is it kind of bloats up your game because unity tries to be intelligent when you make your game it's going to decide what assets you're using and which ones you are not using and that's how it decides what to actually like put together for the game's executable resources breaks that rule because anything anywhere can use it but the usefulness of resources is that you might have something like uh i don't know like a predefined i think we use it for example uh we have a scriptable object that has like player settings in it and anywhere in the code that can just be loaded up you know it's handy for like universal kind of assets so again this is blog standard right so let's talk about addressables so i have another thing show me stuff addressable now if i go to addressable object i'm just going to have a prefab right here and you'll notice if you have the addressables package loaded in you'll have this little check box says addressable you check the box boom and this one's called better stuff and if we go to our asset management addressables groups i don't know if it's just me but i lost a little bit of resolution there it's hard to oh no read text my battle language anyway to make anything addressable it's just it's a check box default objects are like this check it boom it's addressable and whatever you put in here it's going to be very important this is the name of the addressable and it's going to show up in this default local group and says look i have better stuff right so i now go to my code and now i have show my stuff addressable this is the exact same thing but look we have our name addressables instantiate async stuff name and stuff parent we actually just got rid of a line of code this is one line of code whereas whereas resources takes two lines of code we have to load it and then we instantiate it in decimals it's one and done so i have that on here show me stuff addressable change my button to do it now hey shrek before you get too far into this try yep dropping your stream and bringing it back up dropping my shirt all right i cannot see anything right now what i knew it see done see all right try this yes no fingers crossed i don't know why discord doesn't like me for some reason all right there we go all right back in action screen i make sure it was like 1080p and 30fps oh okay that might be good enough okay you can back up about a minute and all right so i showed you guys the basic way to do resource loading that's the way it's been since unity unities 2014 or whatever so addressables is basically kind of works the same way except you don't have to use a special folder so i have an app a prefab here called better stuff i check this box makes it addressable and i put a name in for it i'm just going to call it better stuff and so the code this is the code for using resources you know resource load i punch in the string name blah blah but this is what it looks like for addressables it's the exact same thing it's actually one line of code instantiate async will load and instantiate all in one line now the catches this is asynchronous resources.load is synchronous which means that if for some reason resources.load was like a five gigabyte prefab it's gonna freeze the entire game until it's loaded this will run in the background and it's gonna instantiate it as soon as it's finished loading so there could be a lag time but for us this is gonna be really small so if i hit here make sure this is set up yeah i do show me the stuff boom our newest card the evil otaku so that's an addressable it's that simple that's it now we're going to talk about a lot more other stuff but that's how you use the addressable nutshell it's basically just the resources folder on steroids so what do i mean by on steroids well we got a lot more stuff so there's a few gotchas you could run into like this so let me try what's up again uh it dropped out for just a second okay a little low-res but it's working well this is like i'm zoomed in so this might just be low-res because of that but let's talk about something new it looks like it's like some stream compression not sure why weird i don't i don't know um so let me check one thing on let me check my router to make just i'll kick off every other device that's not me on my phone somehow but anyway where is here yep optimized for streaming yeah i don't know blame discord anyway there are a few gotchas you can run into with addressables uh and we'll try them here so with resources this is kind of normal right you know resources dot load and if anyone ever plays around with game object instantiate you know you can do this i can i'm loading a prefab but this prefab has a script on it so i'm saying hey give me this script from this prefab and call game object instantiate and i can show you that works by going over here do it now run it yep that works just fine but if i try to do the exact same thing with the dressables so i say hey addressables load asset async card handler and then you know on the my uncompleted method instantiate it it will not work and this is what's confusing because it will say there is no addressable here it will say what are you talking about you have the wrong address this isn't right i swear to god if it suddenly just works right now i'm going to be confused nothing and instead it says oh this is wrong this is this is an invalid key and you'll be looking at like but my key is correct i'm typing in the right name that's because with addressables it doesn't save the the files are indexed by their file type not by what's on them so because this is a on the disk this is a prefab it is a game object that's what's on the disk and so i can only ever get it to work by using a game object so then i would if i wanted to get my card handler script right here i'd have to load it up and then do gameobject.getcomponent so this will work fine if i do it this way just to prove i'm not full of it i have do it right works fine so what's going on is if i'm going to bring up the group window so if you go to addressable group window this will show you all the assets you have addressable and you can actually see their file type right here and the thing is you're like this is just a game object unfortunately the current version doesn't tell you it just has the icons so from this it's a game object that's the only way you can get it they do this because they don't check the name for uh isolation so you could have better stuff as a game object and then better stuff as a sprite and better stuff as a texture and so you have to specify are you trying to get the better stuff texture the better stuff object whatever whatever whatever you should never really do that it's kind of a bad idea to have multiple things share the same name so i'm not going to show you that but you shouldn't do it so steven once said strings of the devil and i do agree with him so let me show you easier stuff i have show me stuff and this is easier stuff way easier stuff works [Music] uni doesn't really want you to use strings to work with the dressfuls they want you to use asset references and it's just a opaque object and it just plugs and plays but what's really nice about that is in the editor you now have a drop down of every addressable object you have in your project so you're not having to like worry about typos or oh i changed the name i need to go through and update all my scripts it's just nope just got it and it just works that's it like that's addressable in a nutshell super easy as for why you'd want to use addressables there's advantages with memory um so for example if i had a if i had some object or whatever and i you know i slapped this texture on it that whatever so i went to this object i'm just going to slap this image on it or wherever this image lives there we go cool this football card this will always be loaded into memory always even if i don't need it even though i had this button hidden off screen for example like let's say it was like a pause menu i had this image here if 99 of the time the game's not paused well this is just wasting memory space you know but if it's an addressable object like here it's not loaded into the memory until we request it and then whenever we stop using it it gets unloaded from memory so it could just free up space that's convenient um let's see my cheat sheet list of what i should talk about destroy how do you release it oh yeah uh you can either let it automatically happen just by like garbage collection uh or if you have your asset reference so what this returns right here is an async operation and then when it's done you could just do basic operation dot wait is it stuff yeah sorry all the way around this asset whatever your asset reference is there is a release asset command and this will unload it from memory now i caution you about that it's uh be very careful about it you make sure there's nothing in that asset that you need anymore because it will be gone and um case in point um come on should i let it compile so and i will show you what i mean by that so um let's just do it live we're gonna make a script we'll call it no no texture example because this is a problem that bit me in the butt uh the other day and i had to learn this the hard way so i'm just going to make a scriptable object and i will just call it texture example cool oh i alright did cool and what's this got on it it will have a simple texture and we'll just i don't know sample texture you can just mark a texture as addressable you can just do that in my case i had some scriptable objects that had just i don't know we had a whole bunch of data where it was um i can't talk about it but we had a whole bunch of strings like oh this is i want a makeup example this is a car and this is the car's stats and it's mileage and blah blah blah and the last thing was a picture of the car so we had a texture in there so whatever so that's why we were just we were marking the scriptable object as addressable and not just the single texture because it was all one big data bundle and where is my most important thing for any scriptable object is this one line right here this is what lets you make it so cool so we're going to do here let's go to prefabs go to create script object texture example cool so just real quick if there are adjustables they don't have to be in the prefabs folder right that's just ours they can just be anywhere yeah they can be anywhere um anywhere you want the only catch is they cannot be in the resources folder and actually if you have something in here and you make it addressable unity will move it it'll say resources underscore moved i just just for the sake of cleanliness in the project i'm just putting stuff in here so let's slap this let's let's slap this diva carton here my favorite trading card right there cool and we make them addressable whatever so we're gonna do this we're gonna make a like an image doesn't really matter and now let's make something we're going to call it texture breaker because that's what it's going to do it's going to break this texture so let's see blah blah blah we'll make another button and change the name we'll call it break stuff bingo and brick stuff let's go to our break stuff all right here's the scariest thing folks we're gonna do some live coding so see whatever knows it's like whenever you have to show off code the how bad the code breaks determines on how who is watching so if it's your friends watching it'll work fine if it's your boss watching it's not gonna break if it's your boss's boss watching not only what's not gonna break the computer will catch fire if it's your three bosses up you're probably just gonna have a heart attack so just so you know apply that all right so we got this what's that using statement you put in there oh this is addressable assets so we can only read the yellow text weird i don't huh well anyway i have to import these engine addressable assets uh i'm using i'm just going to make an asset reference for you know texture example so here's the fun thing scriptable objects remember what i said that with a prefab it could only be a game object scriptal objects get to break that rule and so we can actually do this we're going to say texture example and this will actually just work we can actually instantiate it as a scriptable object because the way unity writes it to disk it is a texture example file so we're going to say public void show stuff and break it let's try stuff what we're going to do is we're just going to load it up and because i'm really lazy to make this async so i'm gonna make this async async and await is an amazing c sharp feature that unity has started using with addressable assets so normally with addressables you'd have to use callbacks and that's can get kind of sloppy and messy but now i can just do this so i'm going to say addressables dot say load load asset async texture example we're going to feed it the texture example and then i just do this dot task so now i can say texture example tv equals await and that's it now i just i just have it and if you've never used async in a weight before what this does this keyword await says like hey i know you're going to return an async operation handle but i don't really care just i'll just wait i'm just going to wait for it and when you mark your method as async that just means like hey this method might not complete instantly so this essentially like lets the compiler put in a bunch of boilerplate code so instead of having to like make a call back or do an inline or however you want i just i can just i just get to pretend as if i already got it and what really happens is that when unity processes this this just pauses but i don't have a code like that i can just pretend willy-nilly as if i have it instantaneously because we're lazy so you would do this instead of like a co-routine yep like instead of a co-routine or instead of a callback um because uh it's just like it's just a preference there's pros and cons to using async and weight there for example if you're using async and await you can't really do like a loading bar right because the code just pauses until it's finished whereas if you use a co routine you could have you could check the status of the addressable object which would be really handy if it's like you know five gig file you could show a loading bar as it brings up where but you know then you have that mess of i gotta start a code routine i have to do my yield return of what yield return wait for blah blah blah all that other boilerplate but if you don't care you can just say screw it oh wait the only other there is some weird gotchas with this but that's kind of out of scope for this talk just play around with it and just watch as sometimes you'll stop playing the scene and then your code just says i don't care i wasn't finished all right so we got our thing here cool what we're going to do is we're going to take that ui element we had so i got to import ui and we'll just make a reference to it so i'm image all right so we need to go sum image dot sprite equals picture dot well it is it's sprite dot great my bit spro sprite dot and say t e dot sample texture and we're gonna say ah blah blah blah new rect or what height width liquid height have you ever done this before what this is is beauty treats sprites as a subsection of a texture so i'm taking a texture and i'm creating a sprite from it on the fly so i could actually i could have just made my object be a sprite straight up but this is the way i ran into the bug because we had certain objects that would use the texture and certain ones that used a sprite and this i'm recreating the bug i found so if you're saying like why are you doing this i'm like there's a lot of other stuff i had to do for reasons so that's height oh this is x y with height whoops so i've just made it so bubble block creating a sprite cool beans and so your texture is like your sprite sheet but you're using the whole thing yep exactly what are you not liking here number one method for create takes two arguments i promise i have more oh that's right i gotta do vector2.0 and that's fine now it should be fine all right cool so this will work i say that as if i know for sure cool so we have our example asset here cool and we have our image there cool and we got our break button this is our break button and wire up our method and we're going to say break stuff so this is going to work i promise this will actually work break stuff show stuff keep can you give me one more promise no because this is not javascript we don't do promises here async await only get good all right cool break stuff yeah look they worked fine cool so i know i said hey we're gonna break it and everything worked well now i'm gonna talk about labels because that's involved in this giant spaghetti mess and even want to know about labels so let's go to my addressables and go to my groups so i got my my better stuff card my example asset right let's make a label here we'll call it called uh ultra label that sounds rad everyone should have rad label names ultra label what labels do is that they if you don't have like a specific thing you're saying like hey give me all of the thing so let's say i had a whole bunch of you know playing cards i could have a label says you know playing card and then i can say load assets playing card and instead of getting one i now get every single asset that's tagged with playing card and that's what we're going to do here i'm going to tag my example as ultra label and that's fine and i'm going to go back here and say all right instead of this instead of this which we saw worked we're going to do this now like asset label reference the label all right cool cool cool so here's what we're gonna do we're gonna we're gonna say addressables dot load assets plural async texture example and we're just going to punch in the label and we're going to set this in a unity editor you can technically make a label object at runtime but it's not as simple as just playing a string you have to create an object set the string type then pass it in and just don't let's see oh yeah so this always wants a callback so we say hey we have our callback here and then we'll we'll say process callback so this is nice so what this does is that it's gonna call our call our method process callback what is the type it wants it wants what are you wanting yeah a texture example yeah i got it the cool so what it's going to do is it's going to grab every single asset that has this label and it's going to pass each of them one by one into this method and the really nice thing about this is it doesn't wait for the rest of them to finish so let's say i had 300 assets as soon as it finished asset 1 it passes it to this and then the addressable system goes and starts loading asset number 2. so it's it's all asynchronous it's not like it doesn't wait for all 300 to finish it just it doesn't as soon as it gets them that's really nice so anyway i'm going to move this down here and oops te there we go so we're gonna load it it's gonna do it cool and this doesn't have to be async anymore we don't really care so we're because this is gonna pass this callback as we finish things that's really nice so let's make sure this still works so let's make sure this hasn't broken already because if it does i'm going to panic but it should just be fine oh it's not going to work because i didn't sign the label there we go the label look there's all of our labels ultra labeled the best label ultra better than super it's ultra cool look it worked now obviously if i had a bunch of ultra labels it's going to just overwrite them right kind of silly here's where things can get kind of weird though um and this might not work on my machine because i have only one one item and in my test case scenario i had 50 items that broke in this whoa whoa calm down so what we're going to do is this we're going to grab the async operation right and async operations have a completed and this is the method the callback that will fire when this has finished so we're going to say all right cool we're going to add you know we're just going to do this in line because you know we're just kind of ballers like that it's fine so say hey when this is finished well we don't need it anymore right so we can just say hey let's just release it right right dot where is my handle where is my handle i promise at it there it is task dash dot release i swear to god it's in here somewhere the release method for plea if it's the label i'm gonna freak out i have my work laptop like side by side my regular computer just so i can confer with the notes of like what broke and where did it break so double check that how did jonathan screw this up originally the story let's see so what's going to happen though i'm trying to explain this while i look at the code but what happens though is that this completed method fires the moment it finishes downloading all the assets it does not fire after they have been processed so this can actually fire before this does and in the case i ran into at work let's see list ah here we go this is the right method i don't know why i keep trying to call release on the on the handle itself when it's actually this addressables dot release async up bad so this is bad it might work it might not in my case the label i was pulling down had 50 assets into it and i tested like oh look it works it's fine but i didn't check all 50 of them in our case we're using augmented reality to do stuff and this is loading in experiences so i was like oh that's weird that that didn't work oh it must have just been the ar was acting yet because if you ever worked with augment reality you know sometimes it just doesn't want to play nice but this is in short what we were doing and this is what broke we're gonna see if this breaks it i have a feeling this is gonna work fine but don't trust it see this worked fine here the reason why this worked fine here is because it's one asset and because it's loading off my machine it's not loading off of a remote server so this was this loaded ran instantly before this could now i don't have 50 assets in amazon server laying around to simulate this but just so you know this is bad do not do this super bad the way we eventually discovered this is what was occurring is that we put a timestamp we added this timestamp out to the log we just put in you know debug.log completed you know and then we just all of our we had this at the very beginning which was you know started processing and so what we expected was we'd look at our console and we'd see 50 started processing messages and then one completed but what we saw is that we saw 20 started processing completed and then 30. and the last 30 are the ones that just didn't work and it was always semi-random where it happened because it was always weird downloading from a remote server so it was just the speed of your connection so in my case when i tested at one time on comcast and comcast as we can tell from discord tonight it's just awful and so take so i had plenty of time to process these sprites so sorry the texture breaker didn't actually break textures but just know this this this will you up this is bad but okay that's addressable in a nutshell um now i can move on to like talking about how to do content updates with it which are also super easy before i switch gears into that uh steven diva do you guys have any questions or is there questions from the peanut gallery uh we are all good for right now cool do you guys personally have any questions i think it all makes sense yep yeah i'm wondering why you would not use an addressable now that you have this power ah that's an excellent question um so uh there there's weird reasons why and part of it becomes the way the data gets managed um let me do i don't have a way i can show let me do this go down here boom cool it's got this cube it's fine what's gonna let's do this meta let me add a quad to it give me the quad there we go jesus you're trying to get a presentation here i don't have time for these games all right so let's say i'm just going to slap this onto the quad boom right so here's the problem now this is in the scene this is like heart you could say this is like hard referenced into the scene right but it's also part of an addressable actually sorry that card is actually part of an addressable so what will happen and i believe this will show it here if i do this i'll go to my this font's really tiny so i'm assuming you guys can't see this i'm in the addressables groups tab and there's a tools option and i'm gonna go to analyze why i swear it keeps getting smaller i'm gonna go to analyze rules check for duplicate dependencies let me save scene just to make sure and click analyze and see if it comes up with anything it should it do you have streamer mode on in discord um i don't know what that means it's probably not okay that tries to hide like personal information and stuff and i think the unity might be triggering it but i don't know it goes it looks good now so keep going i have streamer mode disabled actually okay but i will do that all right so anyway uh where'd it go yep here we go it flagged it no it's like nothing i gotta do this so new build default build script here's a here's a gotcha you might run into the address has its own build system so before you can build your game using file build you have to go to addressables and do build new build default build and if you change anything seriously in addressables those changes will not take effect until you do this so reanalyze this and this should get flagged now weird didn't get black let's run all these these are just rules it's looking for duplicates places where you unity detected it needs to mark a texture or mark an asset for addressable bundling um and it's there we go yep so basically here unity is saying hey wait a second here this uh ultra rare diva magic the gathering card is marked as addressable but it's also in this scene so what's going to happen if i build my app is that this image is going to get put in there twice once for the scene and then once for the addressable so it's going to be literally two files sitting on the disk doing the exact same thing that's bad so that's why you might not use an addressable if it's like if you have a case where hey i need this asset to be hard loaded in the scene but i don't want to be marked as addressable because then it's going to get duplicated there are two ways to handle that one is to not use an addressable the other way is to make this entire scene addressable and what you can do with that gets wild but we're gonna touch on that in a second so i have a brief follow-up question go ahead well maybe brief so what's i have so one of the things you can do with resource loading since it is a string you can just put whatever you can kind of build a string to create the string that you want right so you could do like something random is there a way to pick a random addressable of a certain type without loading it like pick from the list of addressables uh like do you get a list can you enumerate them before without loading them that is a good question uh so like that's the thing is you can with addressables you can do the same thing with the resource where you can build a string and load an address however to just blindly say give me a rain i'm addressable from it i do might be possible and here's where we're gonna do this something really important to note whenever you have questions about addressables go to your don't go to google go to your package manager and choose view documentation the reason why is that addressables have changed wildly over like the last year or two and it's starting to settle down now but like you'll if you just google it you'll find like documentation from version 0.2 which completely contradicts the documentation now and we're going to go here because we're going to say hey i believe if you do the catalog so the dressables has an internal data file called a catalog then is basically just a giant index of where every addressable is and i don't know if you can just blindly query it but you might be able to let's see where is my remote api come on scripting api there we go so i believe if you pull up the catalog you can do provide release blah blah you might not be able to let's see here we go yeah there's a list of all the internal ids for your addressable assets um now the catch with internal ids they are not that nice and strange it's not stuff and better stuff it's not the string name you gave it that's like a hash number basically um i don't quote me on it but i think you could take that and then like reverse engineer it to figure out what the string it is um it might be like provider id or some provider ids or something so you could in theory find a list of all the addressables in the project and then you could like you know pick a random index as for why you'd want to do that i don't know well i was curious if like you had it like let's say you got an addressable type that's like a card type and you want to pick a random card of like 100 different ones and then just load it but not load all the cards in order to determine which one you want to load if that makes sense actually yes uh i actually have an example prepared for that and it's going to be part of part of my web talk with content so we'll move into that segment so let's talk about content updates so content updates aka if you want to provide new content for your game but you don't want to have to send out a new build a new executable or whatever so that's where addressables are really handy because what are you even doing here asset store get get out go by groups so by default you have this default this window is going off two monitors calm down sorry uni is just excited anyway the default local group when you click on it your inspector will show up and it'll say yes this is local build path local load path that means it's gonna get bundled into your game right but i made a new group called online stuff and it's marked as remote which means this is going to go live on a server somewhere so as for the what url it uses you have to go to profiles and uni cannot decide if it wants to be fat or skinny today and you have your profiles and this is the local path and you probably are never going to mess with this the only thing you want to touch is the last this last one remote load path that's the url default is localhost and i have set up a new one here called github i'll talk about that one a second but we're going to go default we're going to set that true so this is going to look on my localhost for these files so there is a thing a tool in unity that it does not properly explain to you how to use called hosting services you go here you create local hosting and then check this box boom and now what it's going to do is it's going to spin up a little tiny server on your computer to pretend to be a remote server so now you can actually test builds of your game on your computer here's why i say this doesn't explain well what's going on is that from here it's obvious like hey it's hosting this data but if i go back to my profiles you know it just says hey it's localhost build target if you just try that it's not going to work because it's going to look for a port number and you're like well do i punch in 58510 you could or you could do this another great feature they just try not to tell you you may or may not be able to see there are brackets and curly braces over here those are variable substitutions unity will inject whatever that data should be and this is a variable hosting service port so we're just gonna type that in new bracket hosting service port cool so it's gonna at runtime it will swap in this number in here and build target which is where are we boom this right here standalone 64. currently in addressables 1.17.17 what i'm on uh this does not work for me for some reason depending the bill target i have to just let it go blind like that i don't know why that's the case but it is so now if you try this you're like well it's going to work right no it's still not gonna work here's why these profiles don't actually get updated into your project until you do a new build so we gotta do a new build to update that profile cool we didn't actually put anything in there so let's move we're just going to drag drop better stuff in here and guess what it's still not going to work because i just change it so i do another build again and yes this is what you have to do now if you you might say hey wait a second i didn't do a new build but it worked fine that's because your play mode is doing this asset database that's where unity just pretends to go to a server it doesn't actually do it the danger with this is that sometimes there your code will work perfectly fine but it doesn't actually work it won't work properly um that's why you always want to try to use existing build when you need to test things this will tell to actually go to the server and grab it and we shouldn't have to actually rebuild for that so we have better stuff here cool so we should be good to go there good we go there oh let me go here my canvas i got my button show me the stuff and i believe i have a please show me easier stuff actually is yeah so here's the thing i don't have to do anything special i don't have to tell this code here that it's online or local i don't have to know i don't have to care i just say hey it's there go find it it's like all right so i'm gonna say hey got my button set this back to show me easier stuff do it and fingers crossed this works and i don't have a firewall issue happening in the background with discord and stuff boom look it worked and yep and you can see in the console there's the server the server just said hey this thing just reached out and downloaded this file so unity sets up the hosting services to let you do really complex things like you could run this on an actual like server like amazon server if you wanted to to do some crazy wild thing that's a lot of effort i don't really know or care long story short when you do your build script i'm going to where is it yeah this is wrong folder when you do your build script it generates a new folder out in your project called server data you just drag and drop this into whatever file server you have because inside is all these bundle files that uni will download it's that simple in fact it's so simple you can actually kind of cheat discord and do it i mean cheat github and do it with github and let's see if i can make this work um so this project is on github and i will pull up a link in the other window just in case there is so github if you don't know it allows you to put a website branch in your repository and it will oh there it is wrong there it is so this is the this is the main branch this is this entire project is online right here um we're gonna post this link somewhere but i have made a side branch called server data and it's all it is is this folder in this file so to do this you just make your branch put your stuff in there then you go to your settings your pages and you say hey make this branch a website and it says alright boss i got it and it's just basically a plain file site so if i go back to here go back to asset management i'm going to say hey use my github url set this active i'm going to say go back to my addressables groups going to say do a new build save and continue yes and so are you saying we can use github to mine dogecoin no because it is just a plain file server it doesn't do anything fancy but in our case that's that's all we need to host these content updates or to host content period so doing a build save and continue what is it not that's oh i have my scene running whoops no one saw that no one saw that there we go well now i'm paranoid make sure unity didn't like undo everything okay we're set to github cool we do a new build default build script and we wait as it panics cool built done so we have our so i have server data folder right here and then i have a duplicate branch checked out to here so i'm just going to say all right cool drag drop copy paste bing but a boom let's open up git and we're going to say looks like my previous build did a 32-bit build somehow that's fun all right so say get staged everything it's fine hit commit file updates oh cool now the the get website protocol might take a minute or two to update but we can always just try it right now just see what happens so hit run it show me the stuff let's find out good luck there we go and it just downloaded from the remote server from github boom so what you can tell is like yeah you can see this console message here of my localhost but you see it says it's hosting it but we never got a message that downloaded it from my server so that means it downloaded from github there you go that's how you could easily do that now to answer your question about like hey what if i had like a random file or something you know and i'm gonna combine that with uh hey what if i do need this image in the scene but i also have an addressable let's go do something weird let's do this we're gonna take this whole scene and make this entire scene addressable like that boom sample scene fancy we're just leaving that i don't care so now we go to our build list uni has automatically removed sample scene from here and that's fine so now what we'll do is uh i'm gonna make a scriptable object and i'm just gonna i'm gonna be really lazy with it i'm just gonna call it asset list and what's it do it's got a list of asset references and that's fine so i made a scene called preload this is the very first scene unity will load up and in it it's going to load a scene cool so this would normally load our sample scene but you know what we're just going to ditch this get rid of the u so instead we're going to say say load scene list we're going to do is we're going to make a script that is going to load that scriptable object we just made and you might be like but jonathan why i'm like oh that's right i forgot to explain why but you and i'll see i'm gonna add in addressable assets cool and then this is gonna be public asset reference this is a scriptable object i can just type it like that asset list and i'll say hey it's seamless cool i'm back but jonathan what why are you doing this i'm like oh yeah let me show you come on so go back to here this is a not that go back to my prefabs and say create object asset list let's call it seamless but i like the name cool make it addressable and let's make this we're going to add in this scene sample scene because now we can we can actually load scenes with addressables just like that just like you would normally but now it's addressable and so what i can do if i go to asset management addressables groups i can just say hey we can just make this seamless on our server and just for kicks and giggles we can even move this scene to our server that's fine too but we'll leave it where it is and so now we'll go back so we said hey we got our seamless cool we're going to say let's see stressful dot load asset async asset list scene list and let's just do some kind of in line an inline callback it's the devil i know but hey man it's how i roll sometimes inline fallback why are you not liking this oh it's an arrow anyway sorry i said hey we're this is all i'm doing an inline callback so this method right here about the right is going to get fired when this loads all right cool so we got this scene list right and we know that the uh asset list sl equals our async operations yes where are you oh oh this is the sls i'm stupid i'm not bad i'm used to dealing with lists of things so uh so there we go so sl we have we know it has a list of asset references and we're just going to get the first one from the list we're just going to blindly do this you know who cares about index out of bounds that's fine yeah so asset reference first scene equals this cool so now we have the the reference to our first scene and then we're going to go hey addressables dot load scene it has a special load scene async method that you have to use for scenes it's in async and we're just going to say first scene and it has a built-in activate on load priority blah blah the standard stuff cool and we'll just do that so now we slap this into our scene after it compiles whatever gets around to that so there we go let's say load steam list we'll set our scene list save and oops let's go here because we're testing this i don't have to bother like pushing this up to the server so i'm going to switch this back to asset database mode because that's just it just pretends so there we go and let's see oh yeah i always gotta do new build because we were tweaking stuff you can do it i promise there we go so now boom look it looked it worked so wow it just loaded that from a fake remote server in our case so now it's like all right cool so i just i decided this i just i don't know why i hit play so fast i double clicked it i got excited but yeah so now it's here cool so here's the cool thing about making a scene addressable earlier we put the um the ultra evil otaku trading card in our scene and uni was like hey wait a second here this is a duplicate asset well if we put it in a addressable scene it's fine uni will say hey you're gonna have a duplicate but we can just fix it for you and you just check a box and it will shuffle the assets around so it's not no longer an issue so so let's do this now let's do this let's show how to do an actual real update let's turn this back to localhost let's see set active cool set active boom and new stuff we got our cool so here's the thing to note right this uh sample scene this is actually marked as being local it's going to be built into our game but our scene list is going to be marked as online and this works is going to be really cool if it doesn't well then i'm sorry so we're going to do a new build we build our assets out this creates all the files in that server data folder cool and then we're gonna go to build settings let's make another build that's cool build and do a pentagram make it go faster don't ask why this just works promise say look how fast it's going jesus oh see i stopped doing it froze all right so now let's double check this is our build right here we're gonna run it i hope this doesn't screw up discord i assume you guys can see it launched up and everything and look it it worked it loaded the scene show me the stuff there's evil attacking it's great all my hopes and dreams so now we're gonna do this or it's like hey wait a second here do you know what today is guys does anyone know what today is very important day well this is where let's say you publish this awesome game and suddenly they go duh comrade it is slovenia army day and you say yeah well we need a slovenian flag and better accents but better accidents are outside the scope of this talk so we're just going to throw in the slovenian flag so now we can have a holiday it's slovenia flag day that's cool but you already built your game you don't want to do a whole other executable so then what you do is this whenever you make a new build a little folder gets popped into your project called windows or android or whatever the platform is it generates this addressables content state this is basically a log of where all the addressables are and their files are so this is very important so this this is going to be like this file right now is like this is a list of where all the files are with the last build of the game i just shipped out so i'm going to say hey i'm going to update a previous build and it's going to ask for this file so we give it this file so now it knows that it's like hey we got some updates here whoop oh i forgot to i forgot something my bad forgot one last thing on our online stuff we have to check a box called build remote catalog that allows you to do remote updates probably the most important thing and oh it's in the top level settings my bad let's see blah blah blah build remote catalog build path uh doesn't matter say remote build path remote load path there we go that way it looks for it on the server i gotta do a new build cause i changed oh because i changed the addressable settings i need to go and change this back to not slovenia flag day i'm sorry just so i can show default so we're doing so let's try this again all right i was so proud of that joke too i looked up what today is slovenia army day and i just man anyway i guess that means your boss will eventually see this talk no i don't know if he does i haven't mentioned anywhere where i work and i've like told him all this stuff like way beforehand he's gotten random like messages for me at midnight it's like i figured it out he's like go to bed all right so built that cool rebuild this yeah should be much faster i just went to google and looked up like what holiday is today and today is slovenia army day so cool let's check to make sure i did this right so this should be what we see a blank scene red cube and our diva trading card show me the stuff boom cool the fact that even loaded up is what's important all right so now we're gonna go back to here we're gonna say all right cool it is now time for slovenia it's gonna go update previous build and we're going to go to windows and say this and we're going to say all right open and it's just going to do some stuff yes save and continue going to say hey we should get a message saying build completed whether that's our build or not i don't remember but now fingers crossed i didn't screw this up live as is always the case up up it's loading come on you can do it i believe in you maybe not i don't know if the stream is black that's currently what's happening on my screen too what happened let's find out well that wasn't supposed to happen that was supposed to work i knew it i knew all my tempting fates with jokes was going to happen so what we just did we just pushed an update out and it should have worked so let's see a play mode script use existing build this will pull from the server and let's diagnose what happened see this worked fine we just pulled from the remote yeah it even says pulled from a remote server weird i don't know why that broke live i don't know i'll diagnose that later anyway what i was trying to show was like all right this is how you do an update but more importantly what you can then do since we've used a scriptable object i could just make a whole bunch of these scenes and then i could say yes load this descriptible object and then pull a random number from this list to answer steven your deck of cards question so this could be how you could add or remove or rearrange scenes after the game's already shipped now the one big ultra huge caveat once the game has been shipped code cannot be updated code can never be sent via content updates uh content updates can contain literally anything except new code now i can add scripts to it that's fine but if i try to add a script that wasn't in the original build it's not going to work now as for why why it works in the editor but not in the in the uni thing let's do this again let's diagnose some stuff live let's find out so for anyone that doesn't know this uh all your logs get shoved into app data local low and let's see where it put them on my project settings default company best company default company let's see let's see mgd addressables lesson that's what we're doing so let's see what happened in our log see if we can diagnose what happened live on tv object reference not set to an instance of an object neat let's see couldn't be loaded because sample scene.unity could not be loaded because not been added or the asset bundle has not been loaded neat so probably what happened here is this but our load seamless and we said load assets async this load scene async probably what we need to do is this let's do this stressfuls dot load asset async and we're gonna do this first scene and what oh it wants a callback oh it just should be a uni scene scene oh i'm missing an import you're going to need the engine dot scene management if you see there we go it's a scene yep dot unity file all right and we're just gonna do the exact same thing here we're just going to say hey when this is finished loading paste up async up dot on complete say dot completed uh whoop s buddy get out of here so here's the thing i have to double check the documentation on this but i'm betting what's happening here is that this does not download the scene this does um so i'm betting this is like yeah this this has to assume that this scene has already been downloaded so this is probably what's going on here we're gonna give this one more shot but if it doesn't work then i'll just call it quits for night because right we're almost at 7 30. so on completed s is let's see dot result we don't really care what what it downloaded we just needed to have it downloaded so it's there so we're going to say cool so now we should be able to say load scene exciting let us find out if this is the case one last chance fix this live redeem myself something something i don't know insert insert catchy rap song in post-production that itself is a joke because as diva knows we don't have post-production all right let's test this one more time we'll set this back to default boom stressful's new build rebuild this cool beans go back to our preload make sure yep set to our scene list asset and our scene list we don't really need all these but it's fine it's the same thing over and over again so now we just do a new build blah blah blah all right third time's a charm there we go make sure it works scene should it should load up a scene it should be blank yep it's blank and show me stuff yep so put out this now let's try our content update and let's see go to this scene and let us bonus points to anyone that knows why today is slovenia army at army day because i do not because i'm a slovenian history buff but just because i looked up on wikipedia and i was curious and that's why i wasted half my afternoon reading about it you just say that it was a war that lasted for 10 days very efficient all right so we saved the scene cool update previous build one more time open building so if this was on a remote server you would just post that assets then file to to your server no you would just the only thing to post is the server data folder uh which i don't know where it went the assets bin is what you need to keep a log of like in your version control so for example if you that way if you ever you send out updates you can know for certain that this file is correct if you use the wrong like for example um let me give an example typically in git your master branch is the version of your game that is currently released out there in the wild like that's what's on steam that's what's on switch that's what's whatever so you make your build and you put it out there that when you make that build it regenerates that addressables.bin file but let's say you forgot to save it so you have an old version well if you make a new update it's not going to work it's just going to throw errors because the everyone's unity client is going to be like hey i'm looking for this file and then i'm asking the server for it but the server has no idea what's going on so that's just that file is just like a snapshot of what was the last it's basically a snapshot of what addressables are bundled into the game and that the game knows about so that way let's see even if yeah so even if you posted the new data to your server the clients wouldn't know about it unless they received that file the bin file not the bin file so when i marked that make catalog external this is a catalog it's a json hash file and i think it's just yeah and this file is just a list of every addressable that the server currently is serving and that's what the clients pull from the server to see what they have the bin file is a list of all the see this local group here this is marked as local build path this means this is bundled into the game it's not on the server that bin file is a list of every file that's been bundled into the game so the reason why that's important is that the scene that we just tweaked and added the slovenia flag to is actually local it's already bundled into the game but we just made an update for it that update is going to be on a server now and so this is that's why it has to tell it so they're going to go online and check and says oh wait a second there's an update i need to download and use so here's hoping that this works now let's see black screen of death let's do it okay well i don't know i'd have to figure out why it's not loading that scene dynamically it could be something weird with scenes but that's all we have time for tonight so let me try to answer try to answer that question better um there's two types of addressables come in groups you make groups you can make more as many groups as you want and there's only two types though there's local groups and then remote groups and remote groups are like on servers and whatnot your remote groups when you build them are going to have that catalog.json file that has a list of assets your local groups are technically bundled into the data folder of your executable it's uh believe it's in here somewhere anyway yeah it's uh it's in here somewhere i think it's the resources.assets so the bin file is a list of all the addressables that are bundled into the executable that's why it's really important that you keep track of that bin file so when you make an update it can reference like the uni will say all right i know which files that they were shipped with that they already have built in therefore i can create a delta of what new files they need so that's my answer now as for why this network this could be something weird about it doesn't like me updating a sample scene this is valid you can make an update to a local group that was um that was built into it this is valid the problem with doing that though is that uni will not delete this so let's say i had some like one gig 4k movie in my game and then i updated it later they're still gonna have that one gig 4k movie taking up space on their hard drive it's just it's just dead data because they've already downloaded the update that uses something else instead so generally you need to have a little bit of forethought into what's going to be need to be updated versus what's going to be local and be built in uni also wants you to change this as your update restrictions like both these groups are marked as can change post release but you could also mark them as cannot change post release um as for why that's just getting into the nitty gritty of like memory management and space um however setting this to cannot change post release is also a lie you can do this however you can then run um they was they have a was it check for content update restrictions will allow you to update this anyway you basically said hey i lied i said this was never going to change but i lied it's going to change anyway but right now if you're just starting out this is easy peasy setup there's tons of advanced options to play around with the only thing i ever recommend people might look into is um your groups are individual files so if i open up my server data group to show what i mean there is a group called online stuff if i made a new group it would show up here so the problem is what if i had like a billion things if i had like 52 custom cards in here but to go to your example i only needed to download one the issue is that it's going to download this entire group when i only wanted one so that's why you might want to have to be like sort out your groups however if that is the case there are options in your bundle mode packed together generates things as one big fat chunk but then you could do packs separately if i do this now we'll see two different files instead of one big fat online stuff and yep now we see seamless dot asset and where's my better stuff weird i don't know why i ate that but yeah go ahead are the bundles are they cached offline like or yes they check for updates or how does it like when you run your client the client actually checked to see if it's changed or does it just if it has that cached it's going to keep using that cache so uh the first time you access addressables um it does check for the online catalog file uh just just to see if there's an update with that and i believe there is yeah this hash file you see it has cat like dot json and then dot hash dot hash is one kilobyte it's tiny it's literally just a number so it does a quick check to say hey is the number changed if so i need to redownload otherwise yeah unity does cache it default mode is it just it lives in the cache until it runs out of space but you also have the option of like clear the cache when you load a new version or whatever you also have your own ways if you want to manually handle that you can really get nitty gritty with it but generally i don't think it's a big deal um but i think they're just trying to cover all their bases for whatever possible use case you could run into i'm just thinking you were mentioning like if you had a 4k movie that they downloaded that you no longer are using if you had that set to keep only until the cache version changes or whatever then it would delete that locally correct okay cool so they also have other options here like this is a i can ask like technically these are asset bundles and they have ways you can change it to use like oh use a json asset provider or text data or virtual blah blah blah i've never messed around with any of that and so i can't tell they don't have any documentation currently on what those are and i don't feel like going through their code for something the default behavior is just fine for me and again this is supposed to be like easy peasy crash course mode if you need to get to the nitty gritty then you probably already know what you're doing hopefully so that kind of wraps up my talk so uh diva and stevens what questions do you have for me from you guys just like what i may have glossed over what i didn't touch on or what do you guys have questions with i'll take that as a good sign yeah i think um i'm good so like the the main takeaway is if you want to have like dlc content stored on an amazon server or something all you have to do is just drop that that windows 64 folder onto your you know amazon bucket or whatever and then just point community to it yep um or like if you're doing like a mobile app and you have an ios and android build it'll make an ios and android folder and again drop it onto the bucket um the only other thing you might the only other gadget you might run into is if you do if you're trying to test your builds out the way we do it at the place i may or may not work because i can't talk about that because blah blah blah is we have we have the default profile which is production that's the actual app itself and then we have a test profile that points to a special secret test server and we have a build script so we have and get we have a master branch and a test branch and when it checks out the test branch when it it changes the profile to use the test server and then it builds the assets deploys into amazon builds the app and sends it to test flight so that's the only other thing it's like you have to be uni will append the timestamps to the file so they don't overwrite each other but then you need to have some kind of like oh why is my amazon s3 bucket like 30 gigs it's like oh i haven't cleaned anything out i've done a lot of updates alternatively you can change it so unity will overwrite and reuse the same file names over and over again which makes it easy but then you run to issues where you have incompatible mismatched versions so i think you had a question stephen oh yeah can you deal with like permissions and how do you deal with the request that it's actually making to the server so the default way it is right now it's just it's just a plain request they actually have in their api and i've not messed around with this because i don't need to but they have an authentication hook that you can do where instead of just silently in the background like downloading the catalog it goes through an authentication step of your code and you authenticate and blah blah blah so that's going to be kind of on you uni doesn't really do anything with that other than just give you a hook and i believe if i still have it pulled up here they have it marked as blah blah blah where is it oh they have it in oh come on download it well i i lied it's in here somewhere that there's um they talk about how to do an authentication step but that's going to be custom based on however you have your authentication set up um gotcha as far as uh like there's always a question like how do you how do you prevent players from like stealing your dlc for free you know that's i mean that's a problem that's not an addressable specific problem like that's just a universal problem um every platform has their own ways to handle that so like something interesting for example steam and nintendo don't really like you doing your own content updates like they're not gonna steam won't really care but nintendo does the way they prefer it is that you just make an entirely new build of your game and when you upload that to their servers their servers will actually create the delta patch to download it so in that case like worrying about people secretly stealing your dlc it's just not an issue because it's you never have it remote and everything's local so as for other platforms i mean that's just going to be kind of on you to have some kind of built-in version check like hey just because we have the dlc file downloaded do they have permission to access it that's again that's going to be on you and based on what platform you're using so i don't i don't have any direct first-hand experience with that so i can't give advice one way or the other on the flip side apparently using addressables makes it really easy to mod unity games because you can just if they reveal the catalog like we're doing here then you can just it's just plain json so you can tweak the catalog and put your own custom stuff in there and even yuri themselves will actually recommend like if you have a really massive project you have two completely separate unity projects one that just builds the remote content and the other that's just all your code content and you just use them together so that way you don't have to deal with a five gig library import or whatever nonsense you got going on so any other like weird off questions or things i may have glossed over thank you very cool that's it yep i said dresses are really simple and easy to use their documentation is just really bad so yeah it's i swear to god like the first time i tried to use it i was like what do i do with these files where do i put them and it's like i finally found some like youtube video from some guy that was like had five views and it's just like barely spoken english is like and now you put on amazon box i'm like what that's it you just drag and drop why didn't anyone say that it's that simple so yep yeah again there's a that's it i wish i wish i had my cool slovenia flag to work but now i'm gonna have to figure out why it didn't and um something else something i didn't touch on uni added an option i think your mic just broke how about now yes you're good all right weird um but yeah so uni did add a way to do stuff not async and it's in my opinion it's kind of silly but just for example i'm going to copy paste this so i got this cool and then you just do wait for completion and this will just hang out and just lag the entire whatever you don't matter lag the entire scene until it's finished just as if it was the resources.load the don't ever do this this is bad the only time you'd ever want to use this is let me go back to show me stuff easier this method right here instantiate async if you know 100 that this is already loaded into memory then you will that's okay the reason why is that instantiate async will always wait one frame even if it's already loaded even if it's already good to go it still just waits one frame that's just part of the async so doing this we'll just force it to do it immediately but if it's not loaded your entire game will lag until it finishes downloading and obviously that's not really acceptable and uh oh my oh gosh i just realized there's one huge major major gotcha i gotta talk about i know we're like 740 at this point so it's possible to have a weird race condition scenario i'm just gonna do this so let's say i have some asset i'm trying to load up you know and as one does stuff right and let's see blah blah blah asset resource location that doesn't matter okay whatever game object anyway so let's if i did that twice in a row it and it's trying to pull it from a remote server this will actually throw an error on the second one and what's because it's it throws an error saying that hey this is already in process why are you trying to restart the download process and so there's there's some checks you can do here so let's say i don't know if my stuff asset reference has been loaded i can do this i can do stuff dot you know is done is it done downloading or not cool but the problem is even if it's not downloaded it will still that will return true but this is valid come on is valid will return false so if this is true and you know if this is true and this is false then no it hasn't downloaded yet and you need to call in you know load asset async well async asset async however if whoa come on however if it is not done you know and or size if it's not done but it is valid that means it is currently in the process of downloading and then what you can do is this if you have the asset reference stuff there is an operation handle that is what that is what load asset async normally returns and this will give you the what operation handle is currently being used and so now i can just do my whole standard like you know dot completed plus equals or however you want to do it yield return whatever you know and finally you know you might get an error if it's already done and loaded you might get an error anyway um for some reason this is weirdly temperamental sometimes i get errors sometimes i don't um i haven't been able to suss out what's the weird edge case that causes this other than it definitely does happen so stuff dot is valid anyway so this is to recap if if it is done but not valid it's not done it needs to be downloaded if it's not done and it is valid is currently being downloaded so then you just get the handle if it is done and it is valid then it's already been downloaded and you can just do this you say stuff dot operation dot result there you go that's you query the progress on the operation handle yes you can you can do that uh dot percent complete that's the same thing as process this is to float between zero and one so that's how you do like a loading bar or something so and this is yeah but yeah that's this is a weird gotcha however if you're using instantiate this is safe this will always work this is fine it's okay it's it's only happens when i'm messing around with load asset and i don't it's very much possible that this is just a bug that will get patched out in the future this might not be intended behavior doing this whole like testing phase right here um but for now just fyi that's what i've had to do you can check it's also nice because like multiple things can have the same asset reference and if they're already been downloaded you can say all right cool give me the result and that's instantaneous you know that's not like instantiate one frame later that's it's now so cool but yeah progress you wouldn't want to necessarily wait for instantiate async to finish right uh if you're downloading the progress you said you would not want to wait or what right if you're querying the progress you would want you if you're waiting on instantiate async then you're not going to be able to you don't have a handle to the object yet right i believe you do let's see yeah institute async returns a handle okay but that handle is actually it's like um i think secretly it's a static like c plus plus pointer so any any asset reference has a specific handle that only it has and that's like global static so yeah you can if you're essentially async yeah you can check for percent complete on it and even if you came in from someplace else you can do it now the catch is is like you might want to check this in case you don't want to duplicate instantiation because if you call instantiate twice it'll make two copies and that's that's working as intended but it might not be what you intend so but that's kind of the that's how resources.load and dot infinity work already but i digress so uh any other questions i wish this had worked but uh but yeah i know right now it's like we've been going for jesus i've been talking like two hours straight it feels like it's only been 15 minutes but half of that was probably just waiting you need to compile but yeah all right cool questions comments thank you yeah we'll uh we'll post the the github in the description of wherever you're seeing this video and also on our discord neato just about made an inappropriate comment there hey i think i need to update my documentation because i think my my documentation all the getup right now has some swears on it i need to and i've cleaned it up and expanded it before this talk so all right all your swear words are just acronyms there are sentence enhancers they provide maximum flavor see how do i
Info
Channel: Memphis Game Developers
Views: 849
Rating: undefined out of 5
Keywords:
Id: -hUk1XcW_80
Channel Id: undefined
Length: 99min 53sec (5993 seconds)
Published: Sun May 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.