# Tutorial 9 — Include Game Assets (Asset Ripper)

Custom geometry is great, but reusing the actual meshes, textures, and materials from VR Dungeon Knight makes your rooms feel native to the game.
This tutorial explains how to extract those assets legally (for personal use) and import them into your room project.

---

## What is Asset Ripper?

Asset Ripper is an open-source tool that reads Unity asset bundles and converts them back into project-importable files (FBX, PNG, .mat, etc.).

- GitHub: [https://github.com/AssetRipper/AssetRipper](https://github.com/AssetRipper/AssetRipper)
- Latest release: download the Windows GUI build (`AssetRipper_win_x64.zip`)

> **Legal note:** Extracted assets are game data owned by the developer.
> Use them only in your personal room packs. Do not redistribute them in any form.

---

## Step 1 — Extract assets from VR Dungeon Knight

1. Locate the game's data folder:
   ```
   Steam\steamapps\common\VR_DungeonKnight\VR_DungeonKnight_Data\
   ```

2. Open Asset Ripper. Drag the `VR_DungeonKnight_Data` folder into the window (or use **File → Open Folder**).

3. Asset Ripper will scan all bundles. This takes 1–2 minutes.

4. Click **Export → Export all files** and choose an output folder (e.g. `C:\RipOutput`).

5. Wait for the export to complete. You will get a folder tree that mirrors a Unity project:
   ```
   RipOutput/
     Assets/
       Mesh/
       Texture2D/
       Material/
       AudioClip/
       ...
   ```

---

## Step 2 — Find the assets you want

Browse `RipOutput/Assets/` with File Explorer. Useful subfolders:

| Subfolder | Contents |
|---|---|
| `Mesh/` | `.fbx` files — dungeon walls, floors, pillars, props |
| `Texture2D/` | `.png` files — all textures |
| `Material/` | `.mat` files (Unity material format — re-import needed) |
| `Prefab/` | Prefab hierarchies (useful as reference, not always importable as-is) |

Use the names to identify assets — e.g. `DungeonWall_Stone`, `Floor_Tile_01`, etc.

---

## Step 3 — Import into the room template project

Only copy what you actually need; importing everything will bloat the project.

1. In File Explorer, copy the selected `.fbx` and `.png` files into your Unity project:
   ```
   room-template/Assets/GameAssets/
   ```
   (Create the `GameAssets/` folder inside `Assets/` if it does not exist.)

2. Switch to Unity. The files appear in the Project window under `Assets/GameAssets/`.

3. **Meshes (.fbx):**
   - Select the `.fbx` in the Project window.
   - In the Inspector → **Model** tab: set **Scale Factor** to `1`, **Mesh Compression** to `Off`.
   - Click **Apply**.
   - The mesh is now ready to drag into the scene.

4. **Textures (.png):**
   - Select each texture.
   - Set **Texture Type** to `Default` (or `Normal Map` for normal maps).
   - Click **Apply**.

5. **Materials:**
   - Do not copy `.mat` files directly — the GUID references will be broken.
   - Instead, create new materials in Unity (`Assets → Create → Material`), then assign the extracted textures manually.

---

## Step 4 — Use game assets in your room

Once imported, game assets work like any other asset:

- Drag a mesh (or the FBX's sub-mesh) onto the scene to create a `MeshFilter` + `MeshRenderer` object.
- Assign a material with the matching texture.
- Scale, position, and combine with your own geometry as usual.
- Add a `MeshCollider` (set **Convex** off for static geometry) so the player can walk on surfaces.

### Tip — Matching materials

To match the in-game look exactly:

1. Inspect the ripped `.mat` file in a text editor to see which shader and texture names it references.
2. In Unity, use **Standard** shader, assign the Albedo texture, and optionally the Normal Map.
3. Set Metallic / Smoothness values to match what you saw in the ripped file.

---

## Step 5 — Export and test

Nothing changes in the export workflow:

1. Open **AssetBundles → Build AssetBundles** (Window menu).
2. Copy `[bundle-name].rooms` to `BepInEx\data\fantastic-jam-DKReforged\rooms\[bundle-name]\`.
3. Launch the game in solo mode and walk into your room.

Because the textures and meshes are packed into the `.rooms` bundle, the room will look correct even without the ripped files being present on the player's machine — the bundle is self-contained.

---

## Troubleshooting

| Problem | Fix |
|---|---|
| Mesh appears inside-out | Flip normals in Blender, or enable **Two-Sided** in Unity material |
| Texture is pink (missing) | Re-assign the texture to the material slot |
| Collider lets the player fall through | Add `MeshCollider`, make sure it is not marked as Trigger |
| Asset Ripper crashes on export | Export only the `sharedassets*.assets` files instead of the full folder |

---

## Summary

| Step | Action |
|---|---|
| 1 | Export game data with Asset Ripper |
| 2 | Pick the `.fbx` / `.png` files you need |
| 3 | Import into `Assets/GameAssets/` |
| 4 | Create new materials and assign textures |
| 5 | Build bundle and test |

Game assets bring instant visual consistency — combine them with your own layout to build rooms that feel like a natural part of the dungeon.
