title | marp | paginate |
---|---|---|
Unity Basics 3. Assets & Prefabs |
true |
true |
- 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
- 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
- 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
- Manual: Creating Prefabs
- How to turn a GameObject into a Prefab:
- Drag a GameObject from Hierarchy to Project view
- It turns blue - It's now an instance of a Prefab
- You can now create multiple other instances of it
- Manual: Editing a Prefab via its instances
- Open
- opens the Prefab in Prefab mode, a scene where only the Prefab exists
- Manual: Editing a Prefab in Prefab mode
- Select
- selects the Prefab asset in the Project window
- 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
- Prefab inside Prefab
- Manual: Nested Prefabs
- You can use code to create instances of prefabs when the game is running
- Manual: Instantiating Prefabs at run time