官术网_书友最值得收藏!

Adding assets to the scene

Assets in Unity are everything in the scene. This is a pretty broad description, but that's basically true. Assets can be any of the following:

  • 3D objects
  • Scenes
  • Scripts
  • Sounds
  • Animations
  • Materials
  • And so on...

You will see the assets in the Asset panel. You can select them there and drag them to the scene or the Hierarchy panel. You can import new assets from your own storage or from the Asset Store. The last one is interesting--a lot of people create assets to be used in Unity. These assets vary from simple objects to complex structures with scripts, animations, materials, and everything else you might need. Some of these assets are free, others require a fee. Some are to be used in any way you like, others require a license. Ensure that you explore the requirements before you use these assets in your project.

Open the Asset Store in Unity by clicking on Window -> Asset Store or by pressing CTRL + 9. The store should open, and you can now find items of interest. I want a simple object in our scene, so this is what my search looks like:

The Unity store with a guitar, free only

As you can see, I did a search on guitar and set it to only show me free assets. I will pick a nice electric guitar to use in our scene. Select something you like and press download. Unity will now download the asset from the store and give you a dialog showing you what is inside this asset. Remember that an asset might contain a lot of things such as objects, materials, and scripts. So, you may not want to include everything in your project.

By default, the All option is selected. Some assets have a sample scene, which you do not need, so uncheck that if you see it. When you have selected the things you want, click on Import to add it all to your project.

Depending on the layout of your asset, you might find the object in the root of your Asset panel, or in a subfolder the import has created. I choose the Guitar and Amp in the top-left corner of my store, which created a Prefab folder. Prefabs are assets you can reuse; think of them as components. So, I now have a prefab folder that contains a guitar and an amp object. I just drag the guitar into my scene to have it added. It does not matter where you put it; we will adjust the location anyway.

When you have added an object, you can look at the Inspector panel and see the properties. Just like we did with the camera, we can reset the position of the object. If you reset it, the location will be set to (0,0,0), the rotation will be set to (0,0,0), and the scale will be set to (1,1,1).

So, now we have a guitar, which is placed in the same spot the camera in. This will mean that the user's head is inside the guitar, something we need to change. Change the z-axis property of the object to something like 3 meters. This means that the guitar is 3 meters away from the user. If needed, you can also rotate the guitar to make it more visible. In my case, I need to rotate it (-90, 180, 0); a quarter circle over the horizontal axis and half a circle over the vertical axis to show it to the camera.

You can always check the view by selecting the Game view. If you select this and then move things about, you immediately see things as they will appear in the running app. You can also use the Scene view, which is the default view; select the camera first and then choose the Align View To Selected option in Game Object. This ensures that the view is the same as in the Game view, but leaves you with all the editing options you need.

主站蜘蛛池模板: 永顺县| 平果县| 呼伦贝尔市| 新疆| 锡林郭勒盟| 开封县| 凌源市| 犍为县| 江城| 潞西市| 武陟县| 麟游县| 昆山市| 昌江| 安远县| 贡觉县| 凤山市| 渝中区| 枝江市| 紫金县| 娄烦县| 扬州市| 灵山县| 通许县| 长岭县| 南开区| 余干县| 平塘县| 布尔津县| 汉寿县| 偏关县| 阜平县| 安远县| 杭州市| 德清县| 乐亭县| 西和县| 左贡县| 兴仁县| 鹤庆县| 顺昌县|