Google Gemini

    One Prompt → a Whole Sprite Sheet → Unity-Ready Cutouts

    Two small Python scripts power every 2D asset in my game: one asks Gemini for art (a single icon, or an entire themed UI kit in one generation), the other slices any AI sprite sheet into individual transparent PNGs ready to drop into Unity. Both are free, exactly as I use them.

    One generation, an entire themed kit

    Halloween UI kit sprite sheet

    A single Gemini generation: a full Halloween UI kit — icons, buttons, currencies, progress bars, locks — already consistent because it came from one image.

    From sheet to game-ready sprites in one command

    python slice_sheet.py --sheet halloween_sheet.png --out cutouts

    The slicer samples the sheet's background color from the corners, keys it out, finds every sprite as a connected region, and saves each one as a cropped PNG with a real alpha channel. This sheet produced 35 individual sprites in about two seconds.

    sprite 01
    sprite 02
    sprite 03
    sprite 04
    sprite 05
    sprite 06
    sprite 07
    sprite 08
    sprite 09
    sprite 10
    sprite 11
    sprite 12
    sprite 13
    sprite 14
    sprite 15
    sprite 16
    sprite 17
    sprite 18
    sprite 19
    sprite 20
    sprite 21
    sprite 22
    sprite 23
    sprite 24
    sprite 25
    sprite 26
    sprite 27
    sprite 28
    sprite 29
    sprite 30
    sprite 31
    sprite 32
    sprite 33
    sprite 34
    sprite 35

    35 sprites sliced from a single generation — checkerboard shows real transparency, no touch-ups.

    The single-asset workflow

    python gen_asset.py --type icon --name Trophy --prompt "a golden trophy cup" --ref Icons/Coin.png
    1Generate. Gemini renders the asset with a baked-in style prompt per type: icon, circular badge, avatar, or full-bleed background.
    2Cut out. Models can't reliably output transparency, so rembg strips the background into a real alpha channel locally.
    3Normalize. Auto-crop, then scale the subject to a consistent footprint (86% of canvas) so a whole icon set sits uniformly in Unity UI.
    4Deliver. Saves the PNG directly into your project's Resources/Sprites folder.

    The last mile: icons that assign themselves (Unity MCP)

    Saving the PNG into the project still leaves the manual part. I close that gap with MCP for Unity, an open-source bridge that lets Claude Code operate the Unity Editor directly.

    "Generate a Trophy icon style-matched to Coin.png and assign it to the LeaderboardButton's icon Image in the MainMenu panel."

    Where this gets genuinely powerful is batch reskins. Slice the sheet, then tell the assistant: "swap every icon on the shop panel to its Halloween variant." It walks the panel's children, matches sprites by name, and re-themes the entire UI in one pass.

    Command Builder

    Try the scripts

    python gen_asset.py --type icon --name Trophy --prompt "a golden trophy cup" --ref Icons/Coin.png

    Requires GEMINI_API_KEY. Saves directly to your project's Resources/Sprites folder.

    Setup & cost

    pip install google-genai pillow rembg opencv-python numpy setx GEMINI_API_KEY "your-key" # free at aistudio.google.com/apikey
    ItemCost
    Both scriptsFree
    Gemini image generation~$0.04 per image
    The 35-sprite Halloween kit~$0.04 total
    Slicing & cutoutsFree, runs locally
    Gemini

    Requires Python 3.10+. The actual files I use in production, shared as-is.