Getting Started

Requirements

  • Unity 2022.3 LTS or newer (URP not required)
  • New 3D (Core) or similar template

The package is designed to live under:

Assets/PixitGames/BlockWorld/

Your actual folder structure might differ slightly, but the scripts and demo content follow this convention.

Importing the Package

  1. Import the package into your Unity project.
  2. After import, you should see something like:

  3. Assets/PixitGames/BlockWorld/Scripts/

  4. Assets/PixitGames/BlockWorld/Prefabs/
  5. Assets/PixitGames/BlockWorld/ScriptableObjects/
  6. Assets/PixitGames/BlockWorld/Demo/

  7. Open the demo scene (for example):

  8. Assets/PixitGames/BlockWorld/Demo/BlockWorld_Demo.unity

  9. Press Play to verify everything is working:

  10. A chunk-based world appears

  11. You can move with WASD, jump with Space
  12. Left click: break blocks
  13. Drops appear and get picked up
  14. 1–8: select hotbar slot
  15. Right click (or your configured key): place the currently selected block

Core Components Overview

WorldSettings (ScriptableObject)

Stores all world-generation parameters:

  • Chunk size (X, Y, Z)
  • World size in chunks (X, Z)
  • Height & mountain noise settings
  • Seed
  • The list of available blocks and ore rules

WorldGenerator

  • Spawns a grid of Chunk objects based on WorldSettings.
  • Fills the internal 3D array of block IDs.
  • Builds procedurally generated meshes with colliders.
  • Applies ore rules (diamonds, etc) based on depth, rarity, and block type.

Chunk

  • Represents a single chunk of the world.
  • Holds a 3D array of block IDs.
  • Has methods like GetBlock(x,y,z), SetBlock(x,y,z,id), and BuildMesh().

BlockData (ScriptableObject)

Defines a single block type:

  • Numeric ID (byte; 0 is reserved for Air)
  • Display name
  • Icon (for inventory)
  • worldPrefab (visual block prefab used in the world)
  • dropPrefab (pickup prefab spawned when broken)
  • Base break time, pickaxe multipliers, and optional ore settings.

ToolData (ScriptableObject)

Defines a tool:

  • Display name
  • Icon
  • inHandPrefab (visual model held in the player hand)
  • Optional booleans (e.g. actsAsPickaxe) used later by your logic.

Inventory + UI

  • Inventory component on the player:
  • Manages slots (block/tool + count)
  • Exposes CurrentHotbarBlock and CurrentHotbarTool
  • Raises OnInventoryChanged events
  • InventoryUI + InventorySlotUI:
  • Visualize slots as hotbar and main inventory grid
  • Handle drag & drop and selection highlight

BlockInteractor

  • Performs raycasts from the camera.
  • Highlights and breaks blocks.
  • Spawns drops based on BlockData.dropPrefab.
  • Places blocks using the currently selected hotbar slot.
  • Uses block definitions for base break time and optional tool modifiers.

HeldItemRenderer

  • Reads the currently selected hotbar slot from Inventory.
  • Spawns either the selected ToolData.inHandPrefab or BlockData.worldPrefab under a handAnchor transform.
  • Handles scaling and disabling physics on the held item model.

With these components combined, you have a minimal but functional Minecraft-style environment to build upon.