3. Assets & Prefabs

Asset workflow

Materials, Shaders and Textures

  • Materials define how a surface should be rendered: textures, color, lighting...
  • Shaders are scripts that calculate how color of a pixel should be rendered
  • Textures are bitmap images that can be used to draw shapes to materials, but also manipulate material's surface

Using materials

  • Old Manual: Creating and Using Materials
    • Materials are by default applied to the whole GameObject
    • With ProBuilder, you can apply a material into individual parts of an object
  • There are two ways to apply a Texture to a property.
    • Drag it from the Project View on top of the Texture square
    • Click the Select button, and choose the texture from the drop-down list that appears

Prefabs

  • Manual: Prefabs
  • Prefab is short for prefabricated object
  • use cases...
    • GameObjects you want to instantiate, i.e., create, during runtime
    • "Same thing, but what if many?"
      • not necessary completely identical, however!
      • share common traits but have different details

Creating prefabs

  1. Drag a GameObject from Hierarchy to Project view
  2. It turns blue - It's now an instance of a Prefab
  3. You can now create multiple other instances of it

Open & select

Overrides

  • Manual: Instance overrides
  • Overrides dropdown menu
    • lists all the overridden values ("overrides") on this Prefab instance
    • overrides can be applied to set them to be the new default in the Prefab asset
    • ...or reverted to discard your changes and go back to asset defaults
  • overridden values in Inspector are indicated in bold

Extra: Nested prefabs

Extra: Instantiating Prefabs