A prefab is an object that already has its behaviour: for example a button that spins, glows or animates when you touch it. You download it, drop it into your scene, and it is ready, with nothing to connect. Everything is free to use (CC0): you can use it in your games, even to sell them.
You need:
- a project open in the editor;
- an internet connection to download (afterwards, prefabs stay in your project, even offline).
Step 1: download a prefab
- Open the Yop2D Library (+ → Image button, or the Library button of the Resources panel).
- Tap the ⬇ Prefabs to download tab, next to "Packs to download".
- Tap a prefab to download it. To take several at once, tap ☐ Choose several, tick the ones you want, then ⬇ Download.
👉 A downloaded prefab is stored in your project's Prefabs folder: you never need to download it twice.
Step 2: add it to the scene
- In the ⬇ Prefabs to download tab, touch + Add to the scene under a prefab you have already downloaded.
- A "linked scene" object appears in the middle of the screen: it shows the prefab. In addition, a scene with its name is created in the Scenes list (shown under the scene that uses it).
- You can place several: all copies share the same scene, but each keeps its own state (for example one switch on and another off).
👉 Another way: + → Prefab places a placeholder; select it, tap Image in the Inspector and pick a prefab from the grid.
Step 3: customise it
- Run the game (▶) and touch or hover the prefab to see how it behaves.
- In the Scenes list, touch the prefab's ↳ line: its scene opens. Change the image, the text, the font or the colour with the Inspector.
- Open the Blueprint to change what happens on touch (for example add “Go to scene” to start a game).
👉 Everything can be edited: these are real objects and real nodes, just as if you had made them yourself.
Ready-made interface pieces
- ON/OFF switch: one tap turns it from grey to green with an animated slider; it remembers its state in the variable "etat".
- Animated health bar: green, then orange, then flashing red; the life (variable "vie") goes from 0 to 100.
- Popping score: the number swells with each point, with sparks; the score is in the variable "score".
- Pause window: a ⏸ button opens Resume, Restart and Quit over a dimmed background; the phone's back button opens it too.
Add your own prefabs
- From a zip: in the Resources panel, the import button accepts a Yop2D project as a .zip (a single scene): it is stored in the Prefabs folder.
- To share them: a prefab is a small project with a single scene. If you made a nice one that is free to use, tell us about it on the Yop2D Discord.
If it doesn't work
- The list is empty: connect to the internet, then reopen the tab.
- The button doesn't move: start the game with ▶; animations don't run in the editor.
- An image is missing: prefabs copy their images into your project; check the Resources panel.