[Unity] 2.3 project browser and resource organization, unity2.3
Classification: Unity, C #, VS2015
Created on: 1. Project-Project Browser
As we mentioned earlier, the Project View (called the Project browser) in Unity is equivalent to the Solution Resource Manager (Solution) in VS2015. Each Project in Unity can contain multiple levels (* checkpoints file ). Or a dynamic link library (. dll file) that can be called by other programs ).
In short, although all English words are called projects, they have different meanings. For easy differentiation, the Unity Project is generally called a Project in Chinese translation, and the Project under Solution in VS2015 is called a Project.
Various resources and scripts under the Project in Unity are classified by folders, so they are called engineering browsers. The resources and source programs in these folders are equivalent to various resources and source programs under each Project (Project) in Solution Explorer VS2015, the difference is that VS2015 classifies projects by project categories, and then classifies projects by folders and namespaces instead of folders.
You can understand the concept between Unity and VS2015 in this way:
Unity VS2015
Name Poject (Project) solution Resource Manager (. sln)
Folder under project Poject solution folder under project in Resource Manager
Use Management of various resources and scripts to manage various resources and source programs
File Management Level file (*. unity) project file (. csproj)
Resource Assets Resources
Logical Control script (. cs file) source code (. cs file)
The best way to understand these meanings is to open the example project that comes with Unity installation, and then observe the folders and files in the corresponding view and view.
Is the Project view after the example Project that comes with Unity installation is Enabled:
The Project view displays the Project structure in ListView format. After you click a folder in the list, the content is immediately displayed in the right view. A single resource is displayed as an icon and its type (script, material, subfolders, etc.) is displayed ). Move the slider below the view to adjust the Icon size. If the slider is moved to the far left, it will be replaced by another view form of ListView.
It indicates that the top part of the ListView of the project structure is the Favorites (Favorites), which is used to save frequently used items for future access.
You can drag an item in the project structure list to Favorites.
The drop-down box below the Project is used to Create various resources. Its function is the same as that of the Create sub-menu under the main menu Assets. It is used to add new resources and subfolders to existing folders.
There is an option in the Window menu, which can be converted to the project View Single-Column version. In a single-column view, there is only a list of hierarchies and no icon view. The lock icon next to the menu can be used to freeze the current content in the freeze view (for example, to prevent events from being changed elsewhere). Its usage is similar to that locked by the Inspector.
1. Common shortcuts
Shortcuts are available when the project browser view has a focus. The following are common shortcuts:
Ctrl + A select all visible items in the list
Delete
Shift + Delete directly without the pop-up dialog box
Enter to open the selected Resource
2. Scenario (Scenes)
Generally, the Scenes subfolders in the Assets folder contain different scenario files (*. unity). These files contain various game objects and can be used to create main menus and independent levels.
Unity regards each unique scenario (Scene) file as a level. In each scenario (Scene), the environment, obstacles, and decorations can be placed.
Scenario: File --> New Scene
Save scenario: File --> Save Scene
3. Prefabs)
You can use the Prefabs folder to save preset files.
After creating a Prefab, you can easily and quickly create a copy of The Prefab. Each copy is called an Instance ).
To create a preset copy, you can drag and drop the presets in the preset folder from the Project view to the Hierarchy or scenario view.
With a Prefab instance, you can place and adjust it as needed.
4. Add components and Scripts)
Once you have a preset (Prefab) or highlighted game object (GameObject), you can use Components to add other features to it.
To add a Component, you only need to select a Component from the Component menu of the game object (GameObject ). The Component is displayed in the Inspector of the game object.
A script is also a component.
If the added component disconnects the game object (GameObject) from the preset (Prefab), you can use the game object (GameObject) in the menu) -> Apply the change to the preset (Apply Changes to Prefab) to re-establish the connection.
5. Place game objects (GameObject)
After you put a game object (GameObject) into a scenario, you can use the [Conversion Tool] (Transform Tools) on the shortcut toolbar to place it anywhere.
In addition, you can use the value under the Transform tab in the Inspector to fine-tune the location and Rotation Angle of the game object.
6. Use a camera (Cameras)
The camera (Cameras) is the eye of the game. All the content a player sees when playing a game is displayed through one or more cameras (Camera objects.
You can place, rotate, and parent-child cameras like any other game object. Because the Camera is a game object with a Camera Component (Camera Component ). Therefore, in addition to the features of regular game objects (GameObject), it also has some camera-specific features.
Some useful Camera (Camera) Scripts are installed in the script (Scripts) resource package. When creating a new project, you can install a script (Scripts) resource Package at the same time, or by selecting Assets> Import Package from the menu.
The imported script can be found in Components> Camera-Control in the menu.
7. Light source (Lights)
In rare cases, Lights need to be added to the scene ).
Double-click the Car under Scenes to observe the added light source:
There are three types of light sources, each of which is different. The most important thing is that they add atmosphere and feeling to the game. Different Light sources can completely change the game situation. Effective use of light sources is an important learning topic.
This chapter will be followed by a special section to introduce it. II. Assets-saving and organizing various resources
The Assets folder under the Project is used to save and organize various resources in the Unity Project.
1. Resource Workflow
The steps for using a single resource in Unity are common steps, but the basic operations are outlined. For example, the use of 3D grids.
2. Create rough Resources
You can use any supported 3D modeling software to create a rough resource. For example, 3 Dmax and Maya are used. The following sections separately describe which modeling models can be imported.
3. create and update Resources
If you are creating a game and want to add any type of new resources, you only need to create this resource and save it in the resource (Assets) folder. When you return or start Unity, the added files are automatically detected and imported to the Unity project.
In addition, when you update and save resources on the local machine through software such as 3 Dmax and Maya, Unity can also automatically detect the changes and re-import the changed resources. This allows you to focus on optimizing resources without worrying about inconsistency between resources and Unity.
(1) Default Value
In some import programs, you can specify the default value for field reference or similar transactions. To specify the default value, open the object selector on the field where you want to set the default value, and then select a value on the object selector.
(2) Resource Type
There are some basic resource types for you to create a game. Including (a) Mesh Files and Animations)
No matter which type of 3D resource package is used, Unity will import network and animation from each file.
To use a Mesh file only, you do not need to import animations. If an animation is used, you can choose to import all animations from a single file or one by one files containing each animation.
After importing a Mesh to Unity, you can drag it to a Scene or Hierarchy to create a grid instance. You can also add Components to an instance instead of an attachment to the grid file.
Unity will use UV (that is, two-dimensional texture textures) and a large number of default Materials (Materials) (each UV corresponds to a material) to import the Mesh ). In this way, you can allocate the corresponding texture file to the material, and then fill in the appearance of the grid on the Unity game engine. (B) Texture Files)
Unity supports all image formats. Even hierarchical Photoshop files can be imported without damaging the original format of Photoshop. This allows you to process a single texture file easily and smoothly.
Note: The texture size used should be a power increase of 2 (such as 32x32, 64x64, 128x128, 256x256, etc ), otherwise, loading and processing may be slowed down, mosaic may occur, and other negative effects may occur.
To import a texture, you only need to put the texture under the Project's resource (Assets) folder. The texture is automatically displayed in the Project View.
In addition, you need to allocate the Texture to the material before applying the material to the Mesh, Particle System, or GUI Texture ).
You can also use Import Settings to convert textures to Cubemap or Normalmap for different application types in the game ).
4. Import Resources
When saving resources for the first time, you should save them to the resources (Assets) folder under the Project as usual. The advantage of this is that after opening the Unity project, Unity will detect the resource and automatically import it to the project.
Note that Unity uses the FBX export function provided by modeling software (such as 3 Dmax and Maya) to convert the model to the FBX file format. Therefore, these software must have an FBX export package, for automatic calls by Unity.
You can also export it as FBX in the application and save it to the Project folder.
After you add files to the resources (Assets) folder of the project folder, Unity automatically detects these files. After any resource (Assets) is placed in the resource folder, the resource (Assets) is automatically displayed in the Project View.
When organizing a Project View, remember the following important items:
Do not move any resources or organize this folder outside of Unity management. You must always use the Project View to perform the preceding operations!
This is because Unity stores the relational metadata between a large number of resource files. This data is used for where Unity can find these resources. If you move resources in the Project View, these relationships are retained. If you move resources outside Unity, these relationships are broken.
In addition, if you select a resource in the Project View, the resource import settings will automatically appear in the Inspector. The displayed options are automatically changed based on the type of the selected resource.
(1) Add resources in the scenario
You only need to click the Mesh in the Project View and drag it to the Hierarchy or Scene View to add it to the Scene).
When you drag a Mesh to a scenario, a game object (GameObject) with the Mesh Renderer Component (Component) will be created ).
If you want to use a texture or sound file, you need to add it to the existing game object (GameObject) in the Scene (Scene) or Project.
(2) Put different resources together
The following describes the relationships between the most common resources. (A) Apply the Texture (Texture) to the Material (Material)
You can apply the Material (Material) to a game object. After the object is applied, it becomes a Component with a Mesh Renderer (Mesh Renderer Component ).
You can apply an Animation to a game object. After the Animation is applied, the object becomes an Animation Component ))
You can apply a sound file to a game object. After the application, the object becomes a Component with a sound Source (Audio Source Component) (B) to create a preset.
Prefabs is a set of Game objects and components that can be repeatedly used in scenarios.
A Prefab can create multiple identical objects, which are called Instantiation. For example, to create a tree preset (Prefab), multiple identical trees can be instantiated and put into the scenario. All trees are linked with the preset, so any changes made to the preset will be automatically applied to all tree instances. To change the mesh, material, or any other item, you only need to change it in the preset (Prefab) at one time, and all other trees will inherit the changes. You can also change an instance, and then select the game object (GameObject) on the main menu-> Apply the change to the preset (Apply Changes to Prefab ), this saves a lot of time for setting and updating resources.
If a game object (GameObject) contains multiple components (Component) and a sub-game object (GameObject) level, you can go to the top-level game object (GameObject) (or root )) create a preset and then use the entire game object set.
Prefab can be used as a game object structure blueprint. All the preset (Prefab) clones are the same as the blueprint. If the blueprint is updated, all clones will also be updated. There are multiple ways to update a preset (Prefab) by changing one of its clones and applying the changes to the blueprint implementation. For more information about using and updating presets (Prefab), visit the Prefabs page.
To create a preset (Prefab) from the Game Object in the scenario, you only need to drag the Game Object from the scenario to the project, and you will see the Game Object) name text becomes blue, any name for the new preset (Prefab. Now you have created a Prefab preset that can be reused ).
(3) Update Resources
You have imported and instantiated resources and linked them to the preset (Prefab ). To edit the source resource, double-click it in the Project View. The corresponding application will be started and can be changed at will. Save the update. Then, the update will be detected when you switch back to Unity, and the resources will be re-imported. The link from the resource to the preset (Prefab) will also be retained. The result is that the preset (Prefab) will be updated. These are all necessary information for updating resources. Open and save it!
(4) add tags to resources (optional]
If you want to keep all resources in order, adding tags to resources is always a good way. With tags, you can search for tags related to each resource in the search bar of the project view or object selector.
To add a Label to a resource (Asset), follow these steps:
(From Project View), select the resource (Asset) for which you want to add tags ).
If the resource does not have any associated Labels, click Add Label in the viewer )".
If the resource has associated tags, click the tag (Labels.
Start to write Labels ).
Note:
(A) any resource can contain more than one tag.
(B) To split/create tags, you only need to press enter when writing the resource tag name.