Getting started with Addressables | Unite Now 2020

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[NARRATOR] Welcome to Unite Now, where we bring Unity to you wherever you are. [DAVE] Hi, everybody, my name's Dave Gerding. Welcome to Getting Started with Addressables. Just a reminder that we'll be looking at this resource in a minute. So if you want to go to https://bit.ly/AddressablesAssets and grab that, that would be great. As I said, Dave Gerding, I'm an Associate Professor in a department called the Interactive Arts at Columbia College in Chicago. [KAMRAN] And my name is Kamran Bigdely. Hi, everybody. I'm a Software Engineer and aspiring artist. I'm a Unity Certified Instructor. I'm the supporting instructor here. [DAVE] Right on! Glad to be with you, Kamran. Looking forward to learning something about Addressables today with everybody. For those of you just getting in, don't forget to use the Q&A panel, please. That's the place to post your questions. We have a bunch of moderators there who are really expert and know how to answer questions quickly. Nicolas Borromeo is here, Brian Kenney, Andy Jevsevar, and Daniel Hickey. Daniel usually is looking better, but there was no flash bulb available on the picture day, apparently. Ha, ha! [LAUGHS] So let's get underway. Here we go! [KAMRAN] So, guys, you can have different Zoom layout, but that's the Zoom layout that we recommend. You have the main window, and you have the chat in the top right corner. Please ask your questions in Q&A. The ground rules: I'm sure that you'll be respectful and constructive during this workshop. Please have your Unity open. We prefer 2019.3. You can go with 2020.2, but to go smoothly, I really recommend 2019.3. And please have the package, the Addressable package, downloaded and installed. We will go through that shortly. And this session will be recorded , and you can watch it later. So we will go through a quick pre-work overview, and then we'll talk about what are the Addressables, and the actual learning happens in Addressable Challenges, It's the hands-on challenges. And after that, we'll do a quick recap. [DAVE] Yeah, and there should be plenty of time to ask questions. The nice thing about today's session with Addressables, most of you all are going to be pretty familiar with some of the basics here. So we will definitely give time. There's a nice, comfortable amount of time to get all those projects there... [KAMRAN] So the important thing is for the first 10, 15 minutes of each challenge, please just watch the instructor doing things in Unity, clicking on options and writing code. You can take notes, but please don't touch your Unity in that 10, 15 minutes. Just try to focus on what the instructor is doing. And after that instructor telling, now you have the time to repeat the steps that he's done. If you have extra time, you can explore different features options, ask questions in Q&A, and then we'll go to the next challenge. So, Session Goals. First, we want to know why we do need asset management systems, like when we have a lot of pictures, textures, sound effects, Prefabs, so many things, and how to manage them. And so you can consider the games, like <i>The Wolf Among Us</i> or <i>The Walking Dead</i>, they're huge games, a couple of gigabytes. You can't expect your player to just download everything 1 GB on their cell phone and go ahead. So if you go on Google Play, the whole of this game is just 12 MB. It's kind of impossible. How did this happen? We know that it's possible with Addressables. So we're getting started with Addressables and the new way to manage Assets in Unity because they started two years ago, and we want to compare how Addressables compare to previous Asset management approaches, like Asset Bundles, and then we'll talk a little bit about the difference between Addressables and Object Pooling. [DAVE] So Kamran brings up a great point, which is that Addressables are really handy, obviously, primarily when you start using them to pull your Assets in from an online resource. They have a bunch of other advantages which we'll talk about when we get into it. But just to be clear, for today's scope, we're going to be pulling those Assets using Addressables, but we're not going to be configuring the content delivery network side of things. The next thing is once you've got Addressables and your Addressables group set up, you'll be ready to use that, and that's when Addressables becomes really powerful, because, as Kamran was saying, there are folks who have projects that might wind up being a full gigabyte on a mobile device, once they're collectively deployed, but the initial installment in nice and small. And, as everyone knows, when you're selling into the mobile space, you always want that initial download to be really quick because some people will jump off if they have to wait even for that initial download. Okay, with all that in mind, let's jump in and take a little look at demoing how to set this up, okay? So let's see here, I've got to share this other screen. I'm going to show you guys from the... I have a Unity Project open, if my screen will go there. One sec... So, here we are. Now we are looking at this Project. The thing that you need to do to get up and running is first and foremost, you need to grab that Addressables Assets package, which is at the bit.ly website. And you download it, and you're going to wind up with a zip file. It's really important to make sure that the AddressableAssets.zip that you're downloading is not the Addressables package. We're going to get to that in a minute. The Addressables package is a library that we're going to be using, you don't need to install that yet. What I would ask you to do is go to the bit.ly resource, download the AddressableAssets.zip, and then you use the usual import mechanism, which is you're going to come over... and say Import Package > Custom Package. You can see here I have put my Addressable Assets on the desktop and extracted it. If you haven't extracted it, you'll have trouble getting in it, so make sure you've extracted it. The package to import is called LearnLive_Addressables.unitypackage. You can import that. I'm going to reimport it since I already have. And you'll see, on your screen, what I see on mine, except you'll have a completed thing. You'll say yes, and you will import that. And that's it. Also note... I'm sure the moderators, are going to get questions... Oh no, I've got a red line at the bottom. That's a compiler error. It just means we're not quite ready to use Addressables yet, and we're going to get to it in a moment. So let me switch back to the deck so that you guys have a moment to just get up to speed. So this is a moment when you all can proceed. So you see the green thumbs up over here. That means you do some work, but this is quite a challenge, but it is time for you to set up a Project. We'll take a couple of moments here and if you all will follow through, go to the bit.ly Addressables site, get that zip, and we're going to make a Project. We're recommending 2019.3, please. We tested it with that. And, at this point, you're only importing the Custom Assets. You're not importing the library for Addressables yet, the package for Addressables yet. So I will try to answer Miley's question there. Yes, the whole point of Addressables, beyond helping you coordinate your Assets and think about your Assets proactively, is that it's going to let you reduce the time it takes to build and potentially be able to swap out. Because what you wind up doing, as we'll see in a moment, you wind up separating, and for those of you who are object-oriented folks, your separation concerns, you wind up separating your Assets away from the Scene in a way that lets Unity work more efficiently. For me, I'm excited about Addressables because the other thing it lets you do, potentially, is the skill set of building out the paths to your different Assets is also really complementary with the skill set of trying to work in a multi-person team. So if you've got a team, with more than one person working on Assets, separating your Assets out, is also another step in the direction of being able to build more intelligently with others because you now have the capacity to have those Assets separated out from build time even, depending on once you've got your content delivered and network set up and that's pretty cool! What is Addressables? Well, Addressables is a Unity package that manages memory in Unity. That's pretty straightforward. One way to think about what's happening in the Unity ecosystem when things are running is your Assets and your code come off of Long-Term Storage and go into Memory. The Short-Term Storage, that Memory space is often called RAM. Technically, most PC's and consoles and everything that's what stuff's running today. Long-Term Storage is either going to be a solid-state drive or a hard drive or some other kind of storage mechanism like that, so we wind up with Scenes, Prefabs, Materials, Audio, and Video starting in Long-Term Storage, and then moving into Short-Term Storage as we load Scenes, typically. The other thing to be aware of is the stuff that happens on the CPU and the GPU, the Rendering, the Logic, the Physics, Shaders, Lighting, all of those things, those are going to be not the topic for today. For lots of those topics, you can find great resources in Unity Learn and these Learn Live sessions but today's session is going to be primarily about how we move Assets into and out of Memory. So today's focus is about Memory, but the good news is, for those who are also interested in how we can optimize games beyond just using Addressables, next week, there will be a session on optimizing a game in Unity, as part of this awesome Learn Live series, and that's on Thursday, June 4th, at 10 a.m. Pacific Time so watch for that! Okay, so let's get into it. Typically, Unity loads all the Assets for a Scene into Memory when the Scene loads. So if we have a sample Scene here with four GameObjects, they're going to go... and attendant Memory needed for the environment itself, all those puppies are going to go right into the Memory, right when the Scene loads and that's fine in some cases, but for those of you who are further along in learning Unity, know there comes a point where sometimes your projects get bigger and bigger, or you might need the ability to take advantage of making room in Memory for other Assets. And one of the ways to do that is the traditional way of using Instantiate and destroy. And as we'll see in Addressables, we have a corresponding set of methods for bringing objects into Memory using a similar kind of Instantiate method and pulling them back out. Let's look at what happens with Addressables. With Addressables, the assumption is, especially for the Assets that you're using Addressables on, they don't pop into Memory when the Scene loads. There is a little more work that has to be done with bringing those Assets into Memory but the good news is it's not a lot of work; it's a one line of code: Addressables.InstantiateAsync. So you can see that the Instantiate word there is just like the one you might have used before to create an instance of an object from a Prefab, for example, but in this case, you can do the same kind of thing, except you're pulling it out of the Addressables system. And the Addressables system, again, is a place where all the Assets that you want to manage are named, and they're in named groups as well. And this idea of an Addressables Group is fundamental because what an Addressables Group winds up doing is creating a way for Unity to efficiently compress and organize related Assets into one place. And the most typical way to think of that would be that you might have a Scene, a level, you have Assets that are specific to one level, so you're going to have an Addressables Group for Assets that are only in that level. Similarly, you can have maybe a level two, a different level a different set of Assets. And clearly because these things can be online, pulled in from online, you are going to see the advantage of being able to bring Assets in from a remote context, from a server, as your machine's running. Just like with regular Addressables, we can release memory, we can bring another one back in, and so on. So the Addressables difference is that with Addressables, your Assets are logically separated from Scenes and they're managed in named groups. Related dependencies get managed for you. So that means if you pull an Asset out of the Addressables system that has some dependencies, Addressables will understand those dependencies and make sure that those are available when you need them. And as we've been saying, most importantly, by using Addressables, you're setting yourself up to be able to work with pulling all of these Assets off of what is called sometimes a CDN, or content delivery network. And that is really powerful because it means your content can get to your players much sooner, and it means you can update your content and things like this in an exciting way, so that's great. Take a quick peek at our Q&A here. You're going to be seeing that little error in the build. We'll take care of it in a minute. We talked about Unity as a package, manages Memory, Assets in Memory. It's easier to use than Asset Bundles. I know, Kamran, you had some questions about that. [KAMRAN] Yeah, so how is it different from Asset Bundle? Because the previous way that Unity tried to manage Assets was Asset Bundle. What is wrong with that? Why are we using Addressables now? [DAVE] Well, it's a great question and a reasonable one. The fact is Addressables is built on top of Asset Bundles. So it's not really that Asset Bundles is going away as much as Addressables is going to be the preferred and recommended way to get that kind of effect out of the system. Some people had issues with finding Asset Bundles maybe to be a little tricky to use. And Addressables, from our experience, seems to be much easier to use, and it's kind of a much more comprehensive solution to dealing with Asset management at a system level. So this is a really important... Addressables is a key competency for dealing with projects as they get bigger, and as you're going to be dealing with Assets that may change over time. [KAMRAN] I have another question, actually. I think that we have a game like <i>Clash of Clans</i>, which is a real-time strategy, it's like 10,000 GameObject to load at the start. Say, we have that scenario. But when I want to load this level, it's so slow because Unity's loading all these Prefabs and instantiating all these Prefabs, and it takes time. How is Addressables going to help me with that? [DAVE] Well, for one thing, you spend a little more time upfront thinking about which Scenes need which Assets. [KAMRAN] Ah, I see. [DAVE] The other thing is then it lets you... you wind up with what works a little bit like a URL, the things we see up in our browser, a path there, you wind up getting a path to any of the Assets that you want, and that path becomes kind of meaningful because you have thought in advance about when those Assets are loaded. The asynchronous calls mean that your code... you can have a loading screen or some other screen happening, but Assets can be coming in without the rest of the Unity engine waiting. [KAMRAN] I see. I think one thing that I can do is, for example, I put all of my soldiers in one Asset group, maybe like other Prefabs, in another group. and this way, I can load them gradually. It's not like all load everything at once and Unity gets overwhelmed. and they haven't dropped frame rate or something like that. Is it correct? [DAVE] That's right. That's right! And the other thing... I'm looking at our time here... I think that's right. I know that the Addressables versus Object Pooling thing came up for some people in the past, and I wanted to make sure that people understood these are related ideas, but Object Pooling, which is a great technique, and you definitely want to learn it, Object Pooling is where you pre-Instantiate some GameObjects, and you treat that collection as a resource, so that you're not doing an object instantiation at runtime. And that's similar to what we're doing with Addressables. But, in fact, you can mix and match. You could use Object Pooling for Assets that are coming out of the Addressables storage, but just understand that Addressables and Object Pooling aren't exactly the same thing, but they can work together. So whether you want to pull your Prefab out of the regular Asset collection or you want to pull your Prefab out of the Addressables context, in both cases, there are probably advantages to using Object Pooling if you had many instances of that object at runtime. Let's add that Addressables package and create our first group. Okay, so what we see now is our Addressables system. There's a simple screen that's been set up here, a Prefab Scene and a Sprite. Those buttons are going to be wired up for us automatically to some scripts. They're going to help us load a Prefabbed object, and we're going to load a Prefabbed Scene in a little bit... pardon me, a Scene and then a Sprite using Addressables. I want to make sure... Here we go. So AddressablesSandbox is the Scene you want to have open. And the way to find that is in Assets > Scenes. AddressablesSandbox is the one that came with the Asset we loaded earlier. I'll add the package, finally, you guys will be relieved. We'll add our Addressables package... I see what's happening here. These are the resources that we got from the Assets we downloaded. Now we'll add the package, and if you are not familiar with our Package Manager here... I see what's going on, we're hopping from one screen to another... This is the Package Manager. It lets you get all sorts of wonderful code, libraries, and Assets, that you guys are familiar with. I search for Addressables right here We're going to find that there's a whole range. Now here's a little "gotcha" I want you to pay attention, which is that right now, I'm recommending you guys use 1.7.5 for your version. I wish I could tell you to just grab the one at the top, but you should grab 1.7.5. And the reason we're suggesting this, Kamran found that there was a little glitch in more recent updates to the package. If you're going to try to follow on after today's session, then use some of the other Unity Learn content, that there was a glitch that had to do with Sprite libraries or something along those lines. Is that right, Kamran? [KAMRAN] Atlas Sprite. [DAVE] There you go. So, for now, you just use 1.7.5. We'll say Install. This will get rid of this red error down below. The error had to do with the fact that the Script that was included with the package you previously installed was referencing this Addressables library, this Addressables package. So we need this package to be installed. I see Giles' question. Is this going to give us a simpler way to load an Asset in the Editor with the address from Addressables? I think it's simpler, and we'll see that in just a second here. But yes is the short answer. [KAMRAN] I see somebody asked, he has installed the latest version before, and he's worried about maybe things getting messed up. So, not for this workshop. Still, if you have 1.8.4 or 1.8.3, for this workshop, it still works. But you can go back to the previous version. You just update to the older version, and it is okay, like Unity does that. [DAVE] Yeah, you should be alright, and especially since this isn't a live... You're not working on your own project, this is just demo code. Typically, going backwards in libraries can be problematic, but for this demo context, it shouldn't be at all. So I'll put this up on screen. Everyone take a minute. This is a moment when you all should do your work. So you're going to go to Window > Package Manager. You're going to search for the Addressables package, choose the latest build and click, except we're saying latest build, in this case, it's 1.7.5. When you've done that, you're going to go to the Window > Asset Management > Addressables > Groups section. So this is the way we can look at our Menu in Unity. Go to Window > Asset Management > Addressables > Groups and "Create Addressables Settings." And then the last step over here is you're going to right-click and create a New Group. I'm going to switch back and just show you guys that. I realized I skipped right through doing that for you. Let me show you now. Window, you're going to come over here. Window > Asset Management > Addressables and go to Groups. Alright, so we have Addressables Groups, and this is the guy that pops up when you say Window > Addressables Groups. Create Addressables Settings. And we're going to right-click on here, Create New Group > Packed Assets, and then we're going to right-click on this guy and rename it "LiveGroup." This is our first group, and this is the group we'll be adding our Assets into for the rest of the other quick demos. Okay, there we go. Now, we're back up to speed here, and I'll share the other screens so you guys can follow through your exercise, one sec. We're still on time, folks, but we'll have to pick up the pace, sorry for my screen-sharing issues. Take a second here and make sure you are caught up, that you've added the Addressables package of 1.7.5. And then you've created this group which will leave you with a group called Live, LearnLive Group at the end, okay? Good deal. I'm going to take a second here, unshare my camera and hopefully deglitch my sharing while you all work on that, one sec. Kamran, feel free to peek at the Q&A if there's some questions we can respond to. So let's take a minute and move on. I'll take a quick peek at our questions here. So let's move ahead. I'm going to assume that everyone has the Addressables package installed and that we've added our first group, and we will continue. So let's take a quick peek at the next one. The first thing we're going to do is configure Prefab spawning and this will be the first part where we're launching some code from inside of Unity, and I'll do that right here. I think I'm going to just jump in here and show you what we want it to do. So, when we have this all running, the effect will be that when we run the Prefab Addressables, a Prefab Cube is going to be created for us dynamically, and we can even click this many, many times, and it'll be pulled out of the Addressables Group. Okay, so how do we do that? Well, let's switch over to our work-in-progress version. So we have our LiveGroup, right? The very first thing we want to do is double-click on our Addressables Manager over here, and you'll see that we've got the basic Addressables Manager. What you need to do right out of the gate is you're going to say "using Unity.Addressables." Boy, oh boy! Here are the puppies we're going to add another in our... Here are a couple of using references: AddressableAssets and ResourceManagement. With any luck, my Addressables demo will be happy. Alright, so let's just drive from this since I seem to be plagued by the tech devil today. So we've got our Prefab. We're going to go into it. And here's what I need you to do. I need you to go down to your Prefab section here. Go to the Addressables Groups window over here. And you're going to drag your Cube right up into the Addressables section. So first step is drag your Cube into your Learn Live group. This is a completed section, so we're seeing some other steps ahead, but that's okay. When we come over into our Addressables Manager Script, I want you to focus on adding the Addressables Prefab code here. What is that code? Well, I'm going to highlight for you. This is our namespace for Addressables. This is the Instantiate method that's just like the one you would use with a regular GameObject, except because we want our GameObjects to live in Addressables, we're doing it here. And then, last but not least, we will add a reference to this GameObject over here. Why do we need that? Well, back over in our Addressables space, we're going to come down to our Prefabs, we're going to drag the Cube that we have right over into the Asset Reference Game Object. And when I switch back to our PowerPoint, you will see those steps. So step 1 is add your Cube to the Addressables Group, right there, there's your Cube. Step 2 is to update the Addressables Manager Script, and I'll put that Script back up on screen momentarily. And step 3 is to drag that Cube over your Asset Reference Game Object. [KAMRAN] So, I have a hint, or I have something of a helpful hint. So some people when they're writing their code in, like their Script, they might get this red, squiggly line under their using. I guess you had that, Dave. Am I correct? [DAVE] I did, and I know where you're going, but tell us. [KAMRAN] Yeah, so if you got that, close Visual Studio, Do you have it open, Dave? [DAVE] Visual Studio? I have it open... [KAMRAN] Do you have a Visual Studio that had the problematic source code? So we can save it and then close Visual Studio, go back to Unity, and then under Asset, there is Open C# Project. If you go to your Unity application, on the very top, Assets, and there's Open C# Project at the bottom. If you do that, if you open and build your project again, you won't have that issue again. [DAVE] Ah! Well, thank you. My experience, what I've done, my hack with that in the past has been turning it off and on again, so to speak. [KAMRAN] Okay, now you don't have that issue. It's just because Unity, for the first time, or something didn't manage to properly create the project and this kind of recreated the necessary files. Now everything is recognized and IntelliSense will work and everything is ready for you. [DAVE] So let me... I'm looking at our timing here, and I apologize for the tech glitches on my side. What I want to do is make sure that we cover some of the steps coming. So I'm going to take a second and walk through this Script and make sure that this is the ending Script. But given our timing here, let's take a quick peek at this and then we'll work backwards if we can. I'll stick around for as long as needed to help people get back up to speed. Here's what we're looking at. This Addressables Manager Script has a number of SerializedFields right here. One is an image that is for the Sprite that we're going to load in as an Asset in a bit. This one, the AssetReference, this is for loading an entire Scene in and which can also be done using Addressables. The GameObject we just demonstrated, so let's take a quick peek at that. When we run the... Prefab and the Scene... So here, if I click here, I'm loading Prefab. If I click here, I'm loading a Scene. If I turn on the image over here, this is that image that we saw right here. When I turn that on, we can now load a Sprite in like that. There we go. So now our Sprite is loaded out of Addressables. Our Scenes can be loaded out of Addressables, and Prefabs can be loaded out of Addressables. I understand that I'm sort of collapsing a bunch of work here, but I'll show you back on the Script how we're doing that and why we're doing that. Here's how that happened. When you click the Cube button, the Prefab button, we instantiate a single GameObject. That GameObject comes from a Reference, and you'll note that just like we would with regular Unity Assets, we are able to have the Asset coming in via the Inspector. How is that happening via the Inspector? Well, here's our Addressables Groups, right? So the three-step process is you create your Group, you drag the Assets that you want to be treated as Addressables Assets into that group. So, in this case, having moved ahead, we're flash-forwarding time. We dragged a Unity Ball, which is a Scene, we dragged a Cube, which is a Prefab, and we dragged a Sprite into these Assets. When we look at our Addressables Manager over here, these exposed properties, which we saw on our Script, have all been simply dragged in turn from the Addressables Group over into the appropriate place. So this Scene here is referenced right here. And similarly, the Cube is here and the Sprite is there. Coming back into the Script view, this single Script is what we needed to create or instantiate a single GameObject. Addressables.InstantiateAsync and a reference to that Addressable Asset. Here, AddressablesScene, and I know Kamran had brought this up as an interesting point, We're using this AssetReference above, and we're loading a SceneAsync. So Scenes themselves can be loaded Async, and the one property that I thought-- Kamran, you had mentioned, was this Additive property, right? [KAMRAN] Yeah, that's right. [DAVE] So, the idea with it when we load a Scene, if we don't set this LoadSceneMode to Additive, it's going to replace the entire contents of the current Scene. So setting this attribute to LoadSceneMode.Additive means that the Scene that we're importing is going to add on to our existing Scene, okay? It's that simple. Our Sprite is a little different. Here is some code that I want to walk through as well, just in terms of triaging time. When we take our Sprite, we're going to load it asynchronously, and for those of you who aren't yet used to asynchronous operations, what happens is that method's going to go off on a separate thread of processing, and it's going to come back and return its results to a different method. So what we see here is... to walk through this line carefully, we've got a Sprite reference, we want to load the AssetAsync. And when that message is completed, where do we want it to go? We want this event to happen. So this completed event is being added to, plus equals means add OnSpriteLoaded as a destination for when this has completed. So, to say it again: LoadAssetAysnc, when it is completed, it's going to go to this destination, this method. So what winds up happening is when the Sprite has finished loading, we can set the Sprite value in here into the image property. Does that help, I hope? Let's take a peek over here. [KAMRAN] Another thing people might have in their mind that we are using two things in the Addressables Prefab method you're using Addressable.InstantiateAsync, so it's like the Addressable is static class, if you know what I mean, but in the next method, Addressables Scene, you're just calling the LoadSceneAsync on an instance object, like on an AssetReference. You don't say Addressable.LoadSceneAsync. So you might ask, why is that? It's just a preference. So, basically, you can go with both. In all methods, you can use the static class, Addressable.InstantiateAsync, or you can use the method directly on the instance object, like AssetReference, for example, here, or AssetReferenceSprite in the next method. It's just a matter of API. They made this method available for both instance or static class. So it's nothing even special here. [DAVE] That's right. So what we have are just... These are the three most popular basically kinds of Assets that people wind up wanting to load using Addressables, and that's why we're covering it here. And let's make sure... I'm going to linger on this screen for a minute and I think if I do it this way, we'll be okay. Yup, let's see. Maybe I can squinch this guy down a little bit. No, that's too squinched. Okay. So, on the Unity side of things, it's important for people to understand how we got here because we conflated several of our steps, several of our exercises together in the interest of timing. So what we have is this main Scene AddressablesSandbox. It has a key GameObject called the Addressables Manager. The Addressables Manager has a Script. The Script has four exposed properties. The Image is the one that will eventually hold the Image that comes back from this Asset Reference Sprite. And the GameObject is the one that holds the Asset that will come back from loading the GameObject out of Addressables Assets. And the BouncyBall Scene is the one that's curiously named just AssetReference. We should probably be calling that Assets Scene Reference. So, we wind up with three different ways to load our Addressables, and the material that the Assets you need to try and experiment with that are all right in here. We're at our time, but this did not go to my plan, I apologize for my tech things. Kamran, you were great. Thanks for your helping out. [KAMRAN] You're welcome. There's one question that people are asking. There are two people asking, Ankur and Lucas have a very good question. They think that when they download the Assets from remote servers for something somewhere else. Those Assets are going to download in a specific directory or in the memory or storage? Where do they go? [DAVE] That's a good answer. On a mobile device, which is a lot of the cases where you're going to be using this, both iOS and Android have their own rules about where apps can write information. Apps are given their own writable space, typically, and what that means is if you're using Addressables and are going to be fetching things from online, in both the iOS and Android cases, you're going to have to set up your Project permissions... When your app runs for real on a real device, it's going to ask for permission to be able to read and write into its own address space if you're fetching things from online. Because, typically, iOS and Android also want to know have the app sort of declare or reveal to the user that it's going to be talking to the Internet. And on Windows, and I believe on that MacOS, the same thing is true, which is that the runtime process of Unity itself has write permissions within its own subfolders where the binary folders =are executing. Alright, so let's do this. I'm going to wrap it up and say thank you to everybody. What I'd like to do is I'm going to linger in the... and Kamran, you're welcome to stay, if you want, but I'll just pop over to the Q&A, I'll stop sharing my screen. And we'll just talk to people about Addressables in the Q&A. [KAMRAN] Good, yeah. [DAVE] Alright. Okay, let's see here. So, again, thank you, everybody. Let me remind everyone to please sign up for Unity Learn Live and sign up for next week's event, on the optimization thing, and I'll start working through these questions here. And for those who are still with us, we're in after-session mode, we're just answering questions. Where is Addressables Group data saved? So I think we answered that live, that it's going to depend on the operating system, but it's going to almost certainly be in a folder or directory at or below where the runtime executable, the binary code for your project lines are running. So on Android or iOS, your apps get installed. Yeah, that's likely, Cy, it says application persistent data path. Yup, so what that property does is try to abstract out the different operating systems responses to where does this thing live. It's kind of interesting because if you think about it, that's what the group's path mechanism is doing for Assets as well, which is, okay, independent of everything else, give me a path or a known way to retreat Assets, similar kinds of ideas going on there. Cool. Are there any tools that automatically convert Prefabs into Addressables. No, the way to make a Prefab into an Addressable is to have your Prefab and have an Addressable Group, drag that Prefab into the Addressable Group, and you can manage it from there. Okay, thanks, Andy. [KAMRAN] Another question says, how to export a file into an Addressable Group? You just drag it, right? [DAVE] Yeah... Here we go. Let's see. Okay, so my screen should be sharing, right? [KAMRAN] Yes, that's right. [DAVE] Let me know if anyone's got this. But let's pretend I want... I'm going to come in here and just remove these guys, so you can see what it's like to add Assets into the Addressables group again. So here's the Addressables group. For today's project, what we worked on, we added, for example, a Prefab. So you would come in your Assets and your Prefabs, you've created your group, and you simply drag that group into the Learn Live group. The important thing to remember is that after that, if you wanted to-- So let's pretend this guy hadn't been set yet. If I wanted to use this Prefab as an exposed entity here, as an exposed object for a Script, I drag from the Learn Live Group over into the target area in the Inspector, okay? And the same thing goes for the Sprite, for example. So we haven't yet added the Sprite in here. I could say I've got this Sprite. I'm going to plop it in there. I'm doing this dynamically, so there we go. And then all I did was drag the Sprites over. Notice this path. This is really one of the key ideas, which is your resource has become path-defined and also group-defined. So they live under this group. Kamran and I explored... You can only have an Asset in one group, and that's on purpose because the whole point is to have you thinking about limiting the overlap and reducing redundancy. The Asset, the folder is going to be in your application. We had the answer there earlier, but it's going to be in the application path specific to the operating system. I'll scroll... [KAMRAN] Yeah, another person is asking whether we can Instantiate Addressables without reference. The answer is yes, but we need to provide the address as a string to our Script, and then Addressable.LoadAsync, blah, blah, blah, use that string, you go and load and instantiate your Asset. So there are now two ways: you give it a direct address, the string address or you give it a reference to that Addressable Asset. [DAVE] Yeah, right. Showing the Addressable group for CDN is past what we're covering today, but I would recommend going from here to the Learn Live offline session because that will take you a little bit further. The other thing is there are some videos which I think they were going to post in the link, I'm not sure if they still are. You can look there as well. Lance, to answer your question about is it okay to spam it? Right, it's not going to reload or hit it. It's a little bit of a weird question because I'm wondering why you would want to do that. But one of the things that Addressables does is take care of instance management, and so it won't spin up a second instance if it isn't necessary. As far as I know, Ankur, the Shaders that are dependent on a particular project or Asset, when you drag a particular project Asset into an Addressable Group, part of the dependency process should be, and I believe this is correct if you want to test it, that the variant Shaders that you're talking about are going to come with them. That's part of the virtue of the dependency management. [KAMRAN] Another question is, somebody is asking, and it's actually my question too. So we have basically two methods: LoadAssetAsync and InstantiateAssetAsync. So if we load an Asset a couple of times, it actually goes and loads them a couple of times or it just first time it loads it and the rest of the time it just does nothing? How is that? [DAVE] Well, okay, I might have misunderstood when I responded. I believe that the LoadAssets are going to do that call again. It's actually going to incur the network costs, so I don't think you want to do that repeatedly. So I'll amend my response earlier. I was thinking about the Instantiate piece. Again, I'm a little bit unclear of what the rationale is for calling load iteratively on the same Asset. So I'm having a little trouble understanding. [KAMRAN] Sometimes it might happen that you have a part of the code or a piece of the code that it just gets called. If it caches those Assets, so you're sure that, okay, no problem with calling LoadAssetAsync a couple of times. But you really should make sure that you're calling it once. But, again, I'm not 100% sure on that. We can ask it for you and provide an update for a workshop later on. [DAVE] Okay, right on. [KAMRAN] I'm sorry, guys, I have to go. I have another meeting. Thank you very much to all of you and Dave. [DAVE] Kamran, thanks for your patience and your help with all that stuff, I appreciate it. [KAMRAN] You're very welcome. Bye. [DAVE] Take care. Bye-bye. Thank you.
Info
Channel: Unity
Views: 33,490
Rating: undefined out of 5
Keywords: Unity3d, Unity, Unity Technologies, Games, Game Development, Game Dev, Game Engine, Adressables, live content management, Unity Certified Instructor, learning, Unity Learn
Id: 6IlIA2eLk0I
Channel Id: undefined
Length: 56min 11sec (3371 seconds)
Published: Mon Jun 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.