Create prefabs

material

Prefab

Prefab

  1. Create a prefab resource
    Drag the game object from the Hierarchy window into the Project window
    The prefab in the Project is called a prefab resource , and the prefab in the Hierarchy window is called a prefab instance
  2. Create a prefab instance
    Method 1: Drag the prefab resource from the Project view to the Hierarchy or Scene view
    Method 2: Build the instance while the script is running
  3. Replace Prefab
    Drag a game object from the Hierarchy window and drop it on top of an existing prefab asset in the Project window
  4. Instance Override
    When modifying a prefab resource, the changes will be reflected in all instances.
    It is also possible to make modifications directly to a single instance, and doing so creates an instance override on that instance.
    Instance override type: override property value, add component, delete component, add child game object
    Instance override is shown in bold (Inspector window)
    If you change the property of the prefab resource , it will not have any effect on the instance that overrides the property,
    such as the prefab Transform The Position and Rotation properties
    of the prefab resource modify the Position property of the prefab resource without affecting the Position property of the instance
  5. Nested Prefabs
    Prefabs can contain prefabs
  6. Prefab Variants
    The point of prefab variants is to provide a convenient way to store meaningful and reusable collections of overrides
    similar to inheritance

Guess you like

Origin blog.csdn.net/weixin_43796392/article/details/131395611