Addon Lootbox v1.5

To create a LootboxItem, right-click inside any project folder, go to create and select LootBox/Lootbox Item.

Websocket Colyseus v1.5 for Lootbox - Download

1. Creating Lootbox Items (Unity)

To create a lootbox:

  1. Create a currency that represents the box

    • Example:

      • STN = Stone Box

      • HERO = Hero Box

      • ROYAL = Royal Box

      • GOLDEN = Golden Box

    • Configure it normally in your existing currency setup (Monetization / GameInstance).

  2. Create the LootboxItem asset

    • Right-click in Project:

      • Create → Lootbox → Lootbox Item

    • Fill:

      • lootboxId

        • Unique ID.

        • For WebSocket backend, must match the JSON/server entry (e.g. stn_box).

      • currencyId

        • The currency that represents this box (e.g. STN).

        • If player has 10 STN, they see 10 Stone Boxes available.

      • price

        • Cost per open (usually 1).

      • Chances

        • commonChance, uncommonChance, rareChance, epicChance, legendaryChance

      • Rarity pools (RarityItems)

        • Configure what can drop for each rarity:

          • Currency rewards

          • Icons

          • Frames

          • Inventory items

        • Used directly in Offline/Firebase and as source for the JSON export for WebSocket.

2. UI Setup (Unity)

  1. Add the UILootboxMenu / UILootboxPanel to your Home scene

    • Drop the UILootboxPanel prefab into your Canvas.

    • Create a button to open/close this panel.

  2. Assign references in UILootboxPanel

    • Lootboxes

      • lootboxItems: add all created LootboxItem assets.

      • lootboxEntryPrefab: prefab for each line in the list.

      • lootboxEntryContainer: where entries are instantiated.

    • Confirm Dialog

      • Set confirmPanel, image, texts, Yes/No buttons.

    • Animation

      • animationRoot, closedIcon, openedIcon

      • rarityVisuals: one entry per rarity (Common / Uncommon / Rare / Epic / Legendary)

        • Background (optional)

        • SFX (optional)

        • Shake + delay config

    • Reward Popup

      • rewardPopup, rewardIcon, rewardTitle, rewardAmount, rewardCloseButton

  3. How it behaves

    • The list shows one entry per LootboxItem.

    • The amount uses MonetizationManager.GetCurrency(box.currencyId).

    • On click:

      • Opens confirm popup.

    • On confirm:

      • Calls BackendManager.Service.Lootbox_OpenAsync(lootboxId).

      • Plays animation based on returned rarity.

      • Shows popup with correct icon/title/amount.

      • Refreshes the list (so used box count updates).

  4. WebSocket Backend (Colyseus) Setup

Use this if you want the server to be the absolute truth (recommended for production).

3.1 Exporting Lootboxes JSON

In Unity, use the lootbox button/exporter (or the flow you're already using with other data) to generate:

lootboxes.json

Place this file in the folder:

server/data/lootboxes.json

The content is generated from your LootboxItem + RarityItems.

4. Quick Setup Checklist

Para quem só quer colocar pra rodar:

  1. Create currencies for each box type (STN, HERO, ROYAL, etc).

  2. Create LootboxItem assets:

    • Set lootboxId, currencyId, price, chances, pools.

  3. Add UILootboxPanel to the Home scene:

    • Assign lootboxItems, prefabs, confirm dialog, animation, popup.

  4. WebSocket backend?

    • Export lootboxes.json from Unity.

    • Copy to /data/lootboxes.json on server.

    • Make sure you’re using the server build with:

      • lootboxes.loader.ts

      • lootbox.service.ts

      • lootbox.route.ts

      • and app.config.ts mounting /auth/lootbox.

Last updated