Unity -- prefabs and variants

 1. When the icon of a game object is blue, it indicates that the game object is created through a prefab

When we modify the prefab, the game objects created through the prefab will also be modified synchronously (when adding components to the prefab, the game objects created through the prefab will also add corresponding components)

And when we modify the game objects created through the prefab, we don't modify the prefab

2. How to quickly find the corresponding preset body through the game object?

Select the game object, and then select selct in the prefab (prefab) on the inspector (check) interface, and unity will automatically help us select the prefab corresponding to the game object

Selecting open will "highlight" all game objects created through the same prefab

3. If we double-click the prefab, we can enter a space with only the prefab model, in which we can modify and adjust the prefab

4. When we add components to the game object created through the prefab, the prefab itself will not change, but if we want to add components to the prefab, there is no way:

In the inspector interface, select the non-prefab component we added to the game object created through the prefab, click the three dots in the upper right corner, select Add Component, and select Add Component to the prefab

 Analyze the third button at the bottom of the picture below---override 

After clicking this button, the following page will appear:

 If you choose revert all, the component status in the game object will be changed to the same component status as the prefab

If you choose apply all, the components that are not in the prefab in the game object will be added to the prefab


Variants

After we created a game object through a prefab, we modified the game object to a certain extent. After the modification, we can directly drag the game object Hirarchy (level) to assets to create a new prefab -- - This new prefab is called a variant of the original prefab (there will be a notification like the following when dragging in)

Prefab variants are also divided into two categories:

1.original prefab : If this is selected, the prefab variant we created will no longer have any association with the original prefab, and should be associated with a new prefab

2. prefab variant: If we choose this, we are equivalent to creating a sub-prefab of the original prefab. The adjustments in the sub-prefab will not affect the original prefab, and the sub-prefab still has all the characteristics of the prefab, and! the most important is! All changes to the original prefab will be synchronized in the child prefab

Guess you like

Origin blog.csdn.net/qq_51947882/article/details/126454100