Transcript:
So I wanted to revisit a topic from a previous video that topic being how to import from blender into unity and I wanted to revisit that topic because a blender, 2.8 is out with a very different UI. A slightly different workflow and unity has changed their prefab workflow, which changes some of this as well. So what I’m gonna be doing is importing this low poly tree that you can see in front of you into unity now. This object is made up of several different objects. Each of the clumps of leaves is a different object, and the trunk itself is one object now before. I get to doing anything with this model. I’m gonna duplicate this model and I’m gonna duplicate it, not because I need to for this tutorial, but because it’s a good workflow, I’m gonna be making some changes to this model that are hard to undo or make it hard to come back and modify or edit this model, and I personally find that So often I imported into unity. I see it from a different angle. The colors aren’t quite right. I want to make some changes so what I’m gonna do is use my mouse to box select, and I’m gonna press shift D to duplicate the object and then X to slide it on the x-axi’s now. I’m not gonna do anything with that model. It’s just gonna sit over that on the side. I’m gonna be working with the model here at the origin. If I click on my leaf clump here and then come over here, My modifiers. Which is this little wrench tab over here. You can see that they have modifiers on them. They each have a displace and a decimate modifier on them now. I could apply these one by one, and that’s not too bad with a small model like this, but if you have a more complex model that maybe has 20 30 different objects on it, It’s pretty easy to miss an object or miss a modifier. So I want to show you a shortcut A little trick to apply those modifiers all at once so once again. I’m gonna select at my tree making sure that I get the entire object and nothing else what we want to do here is use a function that in the older versions of blender had a shortcut. How to hotkey that doesn’t appear to be available in blender 2.8 but we can get to the same functionality If I come down to the object menu and then go to convert and then I want this option. Right here is mesh from a curve, meta surf and text. So what do we want to do is? I click on that, and you’ll notice that my modifiers on the right all disappear, and they’ve all been applied to all of these objects. Now with that done, I’m ready to combine these objects in to a single object. Now the reason I want to do that is that unity and I would assume other game engines as we’ll deal with or are able to render the scene better with a fewer number of game objects. The actual vertice count, the polygon count is less important than the number of game objects that doesn’t really matter if you’re only going to have three or four trees in your scene, but if you’re gonna have 50 100 or 200 you’re gonna have a noticeable difference in performance between using trees that are joined all together or having trees that themselves are seven or eight ten twelve different objects, so with all the objects selected. I’m going to press Ctrl J. And that’s gonna join my tree into a single object now from here on out. I’m going to show you two different ways. Each have their pros and cons of how to import this into unity. The first way is just to export an FBX model. So I’m going to go up to file Export Fbx. Now there’s other file types you can use. But Fbx is probably the recommended. I would certainly be my recommendation. I’m then gonna navigate to my unity project. Go into the assets folder. And when you get to this window, you want to select this option out here of selected objects and what this is going to do is make sure the. Fbx only contains the object that you’ve got selected in your scene so that we’re not exporting and say the duplicate tree, the camera or any lights that you might have in your scene now often in a larger project. I would have a folder That’s just models. These are just where I’ve imported things, but for this I’m just gonna import it into the base asset folder once. I’ve gotten there. I’m gonna press the export FBX and that’s gonna export it. And if I go over to unity, you can see now that my tree has shown up over here. There’s a short branch tree. If I drag it in, you can see that the tree is there now. If you look over the inspector, you can see that. I’ve got my trunk and my leaf materials. Just like I did in blender, which is great now. Some things that people have tripped up in the past. Is they’ve been trying to use this cycle’s engine to render, and that doesn’t necessarily work real? Well, there’s a ways to get around that, but that’s gonna be the subject of another video now. If you click on one of these materials and you open them up, you can see the color that exists in blender, but you can’t edit it. You can’t edit any of these settings. But if I right-click go to create material and create a new leaf material, Go back to my object in the scene, I’m gonna drag and drop that leaf material into the leaf slot and you’ll see that all the leaves turn white, and then when I open this material now I can edit this now personally. I like to turn the smoothness down, so it’s not shiny, and then I can edit the color of my tree to be whatever I want and I’m able to do that here. In unity, so that’s a great advantage to having these multiple materials now just like having fewer number of game objects. Unity’s going to be happier with a fewer number of materials. And that’s gonna be a subject on my next blender video or I’ll show you how to UV unwrap and bake this texture in blender, 2.8 and import that into unity. That is a couple things you get a performance bump and in my opinion, if you do the settings, right, it’s gonna look better as well. Okay, so that’s one way to import a model in to unity. If you get out on the interwebs, this is how people say to do it. You export the FBX and bring that into your unity project. Now there’s a second way to do this, and this is not as recommended primarily if you’re working on a team and not everybody has blender installed on their computer. I’ll explain that in a bit, but let’s head back to blender. So back here in blender. What we’re gonna do to get this tree into unity is we’re gonna save this blend file directly to our unity project, So I’m gonna go up to file save as and once again, I’m going to navigate to my unity project, my assets, I’m gonna save it when I go into unity. It’s gonna have to think a little bit, especially the first time it opened this and what it’s actually doing Is it has to go into. Blender has to find blender and basically a splendor. How do I deal with your file? How do I import it and that’s? Why it’s not a recommended way of importing models into unity, especially if you’re working on a team because everybody on the project needs to have blender installed on the computer. If that’s not an issue, I think this is my preferred way of bringing models into unity and I’ll explain that in a bit, but let’s first look at what we’ve brought into unity. I’m gonna zoom out here A little bit and drag that second model into the scene you can see of import is exactly the blend file. I have my two trees. I’ve got some lamps and I even have my camera if I open it up. In the inspector, you can see all those objects and this object right here. This object here. That’s the single tree. That’s when we’ve joined all together, and that’s the one that we want as a prefab to use in our game. Now, Unity has made some changes to its prefab workflow, which makes this a little bit harder. A little bit more complicated to deal with, but it’s still not too bad, So if I want to get that object isolated by itself and turn it into a prefab. I got a few steps to do that, so I’m going to right. Click create folder prefabs, and then I’m going to drag this whole model into the prefab folder. We’re gonna create an original prefab, and then I’m gonna double. Click on that to go into my prefab editor. Now what I want to do is grab this tree model here. Which is this single join tree, and I’m gonna drag that into my prefab folder as well and that’s gonna create its own prefab of just that part of the blend file. If I come back into my scene, I’m gonna delete the larger file. I’m gonna draggin this single tree, and you can now see that. I’ve got this single tree imported into blender. You might be sitting there thinking, okay, great, you just imported this a second way, but it looked like a lot more work, but let me show you why that’s a good way to do it. So if I go back into blender, and I’m gonna go into edit mode. I’m gonna grab one of these vertices, and I’m just gonna grab it. I’m gonna stretch it out. Make it really obvious. I’m gonna save the blend file again by hitting Ctrl s. And I’m gonna go back into unity. Unity is going to re-import that model and you can see now that that vertice has been changed directly in my unity scene. So the great advantage of this is if you’re tweaking a model, maybe changing colors changing the shape of it. You can be doing that in blender saving that file, and then when you come back to unity to see how it looks in your scene, all those updates get pushed into your scene. You don’t have to re export the FBX and then put that at that model back into the scene. In the same places, you can see that this really speeds up and smooth out your workflow between blender and unity. So there you go. I’ve shown you two ways each with their pros and cons to import models from blender to unity. So I hope that was useful. Hope that was interesting and may be helpful for your projects if it wants, think about hitting that, like and subscribe buttons. If you want to go further in supporting the channel, check out the links to my patreon and discord in the description below so until next time happy game design you.