Time for action – Importing asset packages

There are a growing number of third party companies who are providing assets specifically packaged for Unity developers, including the Unity Asset Store which can be accessed from within the Unity product. All of these solutions provide content through the same .unitypackage format described in the section Time for Action – Exporting asset packages. With assets from the Unity Asset store, the process of including the assets in your project is automatic. However, there may be times when you have received assets from others and need to import them into your project yourself.

  1. Create a new Project in Unity called Project Import.
  2. Using the .unitypackage file you built from the Exporting Assets Time For Action, import into your project by dragging the .unitypackage file into the Project view at the location in your project hierarchy where you'd like them to be stored, or by using the Import Assets menu (Assets | Import Asset):
    Time for action – Importing asset packages
  3. Once performed you will find that Unity has imported in the .unitypackage file in the Project view, but it has not expanded the assets into the familiar hierarchy that we had before. Unity doesn't know if you want all of the assets in the package and it is giving you the option to decide, rather than pollute your project with an unknown list of assets.
  4. Double-click on the .unitypackage file to have Unity expand the package into its component parts.

    You will be presented with a dialog that lists everything that is in the package, as well as a note letting you know whether or not the assets are new. This is useful when sharing assets across projects, especially when the assets might have the same name.

  5. Select the All button to have Unity include all of the assets in the package:
    Time for action – Importing asset packages
  6. Observe the Project view and you will find that all of the assets that you selected have been included in the Project and that the hierarchy for the assets has been preserved:
    Time for action – Importing asset packages

    Note

    Although we didn't have a Library element in our package, or one in our Puppy Test project, Unity created this hierarchy and imported in the assets accordingly. It is this sort of information, and the settings associated with it, that would be lost if you managed the Assets folder manually.

  7. Delete the unityproject file from the Project Hierarchy since we have extracted the assets we're interested in.

What just happened?

We have just imported assets into a new project preserving the original hierarchy of the assets from the original project.

While we have chosen to import all of the assets from the unityproject it is not necessary to do so. You can preview the assets that you want to import and uncheck those you'd rather not be included in your project.

Game Objects

Normally when you think of a Game Object you think of an animated soldier, a particle system, or a Sprite within a game. However, a Game Object is more of an abstract concept, a base object with no behaviors or functionality. Game Objects gain the ability to perform functions by having behaviors added to them. The approach through which this is done is the Decorator design pattern, which allows some arbitrary number of behaviors to be added to some base class. These behaviors, known as Components in the Unity vernacular, are what give a Game Object true meaning and definition. It is through Components that Game Objects have the ability to exist in a scene and have a position, rotation and scale.

Components

Components are decorators for Game Objects that provide additional behaviors and configuration to assets. Many of the core tenets of rendering, physics, audio, lighting, and so on are all accomplished by adding Components to objects. As such, many of the Unity concepts that we will cover have a computer graphics definition and a component which when attached to that Game Object provides the behavior. The best way to illustrate this concept is through some examples.

You might think that the easiest way to have a light is to have some concrete Light type that is defined in the system. However, suppose that you want a regular object such as a starship engine to have the ability to emit light? Certainly you can create a Light object and associate it with the engine model, but suppose that you also want it to emit smoke and be affected by physics, and play a sound? Immediately you would notice that your scene would be polluted with objects that aren't really relevant to the game – nevertheless they would show up in your hierarchy and you'd have to manage them. The more elegant way to accomplish this is to say that you have a starship engine and it has certain behaviors. These behaviors are the components that we'd associate with the object.

Even our standard Game Object gets its ability to have position, scale, and rotation from a Transform Component. In Unity's Inspector view what you are really looking at is the stack of components that are applied to this Game Object.

Let's take another example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.103.74