1.9 Learning Unity game development from 0--building game package body

We talked about so many scene edits before, how to write a basic code to realize the components we want, and finally run our game in the editor, but this is less than one-thousandth of our way to develop the game process.

On the way of development, we definitely hope to share the experience with those who follow this game after we have achieved certain results, so how to send our own game to others? This requires packaging the game.

For programmers, we must be familiar with how to generate a hello world that others can access under windows/mac/linux. For games, in addition to generating the final executable file, you also need to bring The resources needed by the game, yes, are the scene resource files we have been editing before and so on.

Sound complicated? Don't be afraid, in fact, Unity has already helped us with this whole set of packaging solutions. As long as we use things, they will be packaged in the final package.

Packing operation

In File->Build Settings, you can enter the packaging option box

The following Build And Run is actually the quick entry that you have already configured, and you can directly execute the quick entry according to the previous configuration. The configuration interface looks like this

Speaking by region

  1. It is the game scenes to be included in this package. You can see that the project included by Unity when creating the project by default is not the Demo scene created by us. Then we only need to click Add Open Scenes to open the current scene. Add in the scene, such as the Demo scene we are opening now, then it will be displayed like this after we click:

The tick option is whether to enable the scene, which can be placed here but not packaged.

At the same time, the order here is very important. Seeing the 0 and 1 on the right, the order of scenes is from small to large. The packaged game will execute the scene with the smallest number first, that is, the scene at the top of this list, that is to say, this The scene is the entrance to our game.

This order can be adjusted by dragging the list items, here we drag the Demo scene:

It doesn't matter if you want this SampleScene or not, you can uncheck it, or you can right click and remove it directly.

2. Which platform package should be packaged? Yes, we can support packaging packages for other platforms on Windows. Here I can package Android packages because I have installed the corresponding Android build support. If necessary, you can go to Unity Hub to give yourself The Unity version plus the corresponding platform build support.

It can be seen that in addition to our common PC and mobile platforms, it also includes the game console platform PlayStation, and of course Switch and XBox are also supported, but the developer authorization methods for different game platforms are different. For example, Switch has to be registered. You must become a developer before you can download the build support that Nintendo has done for Unity, so the support for these platforms is not publicly visible, but don't think that it is not supported.

3. Some simple configurations of the build, we will talk about it in detail later, here we will only talk about the most important "Developement Build", which is actually a Debug build similar to our ordinary development program. It is called Dev build in the game, and the meaning is similar. If you check Yes, then the performance of the game package will be checked, but you can see the complete stack when you debug, and you can also connect to various Profilers. Unity will also display an in-game interface to display the Error log content, but if you don’t check it, Then basically there is no way to debug, you can only log and see it yourself.

So if we send it to others for experience, we don’t need to check the Development Build, but we have to check it if there is a Debug requirement.

For more detailed configuration, you can click on the PlayerSettings in the lower left corner of the window. There are many details about this, so let’s ignore it now.

4. Finally, we will click Build and you will be asked to choose a place to put the exe or the output location of the executable file/app package corresponding to other platforms. Build And Run, as the name suggests, is to run automatically after the package is completed.

Generally speaking, the game built on the PC consists of multiple files and folders, so it is recommended to create a new folder to store the build output and avoid mixing it with other files.

Let's just click Build first, and the output is roughly as follows:

Here My project.exe is the startup exe of our game program, and My project_Data is the place where all our game resources are packaged and stored. You can see that Unity games have a very obvious feature. If there is a _Data file with the same name next to the exe Folder, then 99% of the game is made by Unity.

Double-click the exe to run our game, so we only need to pack all the files and folders in the screenshot into a compressed package and send it to others, and others can experience it, and Unity packaging does not require you to copy additional runtime libraries. Steps, unless you use any dependent third-party library files yourself.

next chapter

Well, this chapter is more relaxed and happy. It briefly introduces how to package your own game and send it to others to play. It also briefly explains that Unity supports a large number of platform builds by default. You only need to install the corresponding build environment, unless you use some platform-related features. Otherwise, there is really no need to change anything to support the whole platform.

Speaking of this, Zhihu actually has a lot of information about how Yuanshen supports PCs, mobile phones, and game consoles at the same time. You can see that Zhihu is really a holy place for people who don't understand and pretend to understand. Obviously, Unity can support all these platforms without changing anything. There is nothing mysterious about it when it does not involve the need to optimize for each platform. It's probably embarrassing when the big V pretends to be in his professional field.

In the next article, we return to our game goal. Now that we have basically understood the basic composition of the Unity game world, we need to start to really make some playability for our game, such as supporting user input to adjust the camera Angle, just like the Scene window directly supports navigating the entire game world.

Guess you like

Origin blog.csdn.net/z175269158/article/details/129832327