NO UI Prefabs!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there so I'm still working on this MOBA and yesterday I came across a problem that I needed to solve that I think almost every Game Dev needs to solve and I figured why not share it so if your game has a user interface then hang on cuz in this video I'm going to show you how I do my user interface editing to make it extremely easy to use my UI across test levels like this and my real game like this without having to manage a bunch of prefabs and deal with overrides and other issues that I always run into when I try to do uis at prefabs and the solution is pretty simple it's two simple pieces actually the first is a separate scene for my in-game UI so nowadays instead of putting all of my UI elements into their own little prefabs and then dragging those prefabs out into the scene or anything like that I create a completely separate scene and I don't do this from the start in fact I just did this today I took my scene that had my user interface in it took all of the UI canvases and I just have a separate canvas for each little piece of the UI and then I drug those into a new scene named in-game UI and I don't want to have to load this manually every time I want to work with it or when I load into a specific scene like my character test scene so I also created a simple script and a simple prefab here that loads and unloads the UI it's got a button on here to unload the UI from a current scene that I'm in so if I want to go in and like mess around and work with the UI I can load that scene up start playing around do some changes in fact right now I'm adding a pools UI so I can see all of my pools and all of the stats for the characters and I can go unload it when I'm done if I press play this prefab will just load the object up so I can play and it'll or not load the object but it'll load the scene it'll give us that in-game UI scene in just a second you'll see it appear here and then it just works as long as the UI scene elements are not tightly bound inside of the rest of your game and that's just done by making sure that your UI elements are looking for other objects when they start up so my panels all look for the characters or the local character and then whenever that character changes they refresh their data and rebind themselves and the characters and other objects don't really know about the UI if as long as you keep your Bindings that one way then everything will work and you see I can run around here I've got my characters I can switch between I also have a hotkey here to just switch between all of my characters and another hotkey that doesn't seem to be working that's supposed to let me switch between how many different characters I want to have but it doesn't seem to refresh my UI so I can change it oh you can see I can even a ba Tower or a random spaceship or whatever different things it's a lot of stuff here but it makes it nice and easy and by the way this is just a test combat scene if you're curious what's going on here we've got a test ability scene that I showed a couple days ago um this one does something similar except you actually come in as a character and you battle other characters so that way you can test out the full combat system and test look for bugs look for new things to add and all of that even do balance testing with something simple like okay which one will beat the other one just going head tohe you can see that that particle is a little bit wrong too anyway that's what I wanted to show today this in-game UI loader let's take a look at the code actually before I wrap this up here's the code for it it's again pretty simple there are a couple things that might be confusing though if you're not familiar with the if defines this is just going to make sure that the scene management inside Unity editor part only is loaded for the editor that way if we do a build it will still work and if you copy this code it's still going to work it is using the serenic Odin inspector button attribute here if you don't have Odin inspector you can just remove that and add a context menu attribute or something just go context menu and then yeah give it a name like a whatever load UI and you'd be able to right click on it and show it that way as well now let's take a look at what the load UI button does or the load UI method it just looks to see if we have the in-game UI scene loaded if we do we return and then if we're playing so we're running then we actually just use the scene manager's load scene async and load the level additively otherwise if we're in the editor so we do this check here this if check is a compile time check so if we're not doing an editor thing we've done a build the rest of this method won't exist and that will exit out but if we're in the editor then what we'll do is call this open scene in fact we don't really need this else here but I have oh we kind of do need the else here that's that was a lie cuz if we're playing we don't want the open scene to get called even if we're in the editor so we want the else check as well and then in the unload obviously just checks to see if we have it loaded and then unloads either with scene manager or editor scene manager using the close scene anyway if this was helpful nice little video um let me know drop a comment down below hit the Thumbs Up Button subscribe and all that stuff if you want to see the code for the full game it's as part of the multiplayer Mastery course I've got the code as I'm going along just getting uploaded into there and we've been discussing it a bit in our weekly or bi-weekly calls every Monday and Thursday so we talked about it a little bit earlier today and I'm sure we'll be diving into more stuff on it on Thursday as well and those are going on um for the foreseeable future anyway thanks again don't forget to like subscribe and all that and if you have a different way for doing UI let me know that in the comments too kind of curious what everybody else is doing oh I almost forgot to mention if you want the code for this UI part specifically I'll put a link in the description or you can go to game. courses iname UI I'll put it up there as well
Info
Channel: Jason Weimann
Views: 10,746
Rating: undefined out of 5
Keywords:
Id: 4aMyG51tB3g
Channel Id: undefined
Length: 5min 39sec (339 seconds)
Published: Mon Apr 08 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.