< Return to Video

Prefabs - Concept and usage - Unity Official Tutorials

  • 0:00 - 0:03
    Prefabs in Unity are preconfigured game objects
  • 0:03 - 0:05
    that you create in the scene
  • 0:05 - 0:06
    and store in the project.
  • 0:07 - 0:09
    They can then be instantiated or cloned,
  • 0:09 - 0:11
    meaning to create an instance of them
  • 0:11 - 0:12
    during the game.
  • 0:13 - 0:15
    They have all manner of uses and are a key part
  • 0:15 - 0:16
    of development in Unity.
  • 0:16 - 0:18
    They are used for everything from rockets
  • 0:18 - 0:20
    to enemies, to procedural levels.
  • 0:21 - 0:24
    To make a prefab simply create your game object
  • 0:24 - 0:26
    in it's desired configuration in your scene,
  • 0:26 - 0:28
    from whatever components you need,
  • 0:28 - 0:30
    and then drag it to the project panel
  • 0:30 - 0:32
    to save it as a prefab.
  • 0:32 - 0:34
    It can then be deleted from the scene.
  • 0:36 - 0:40
    To edit a prefab you can either select it in the project,
  • 0:40 - 0:42
    and adjust properties in the inspector.
  • 0:42 - 0:45
    Or drag an instance of it back in to the scene,
  • 0:46 - 0:48
    edit it in the inspector,
  • 0:49 - 0:52
    and then press the apply button at the top.
  • 0:53 - 0:55
    This saves changes back in to the prefab
  • 0:55 - 0:57
    and you can then remove the instance from the scene
  • 0:57 - 0:58
    yet again.
  • 1:01 - 1:04
    Also, if you have many instances of a prefab,
  • 1:07 - 1:09
    and you make edits to one of them,
  • 1:11 - 1:14
    and decide you would like others to be the same
  • 1:14 - 1:15
    you can hit apply.
  • 1:15 - 1:17
    The other instances will inherit this update
  • 1:17 - 1:18
    from the prefab's settings.
  • 1:19 - 1:21
    Likewise if you make a change to
  • 1:21 - 1:23
    one of your instances
  • 1:25 - 1:27
    and you decide you don't like it anymore
  • 1:27 - 1:29
    you can revert to the settings of the prefab
  • 1:29 - 1:31
    by clicking the revert button at the top.
Title:
Prefabs - Concept and usage - Unity Official Tutorials
Description:

more » « less
Duration:
01:33

English subtitles

Revisions