Assets are the visual elements of your mod, including icons, portraits, textures, and other graphical resources. Properly importing and referencing these assets is crucial for creating polished and professional-looking mods. The TypeScript Modding Tools provide a streamlined workflow for importing and using custom assets.
The first step in using custom assets is importing them into your mod. This is done using the ImportFileBuilder class:
import { ACTION_GROUP_BUNDLE, ImportFileBuilder, Mod} from "civ7-modding-tools";const mod = new Mod({ id: 'my-assets-mod', version: '1.0',});// Import a single iconconst unitIcon = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/unit-icon.png', // Path to your asset file name: 'unit_icon_custom' // Name to reference the asset in the game});// Add to modmod.add([unitIcon]);// Build the modmod.build('./dist');
Different game elements require different types of assets. Here’s how to import various common asset types:
// Civilization icon (displayed in the civilization selection screen)const civIcon = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/civ-icon.png', name: 'civ_sym_custom'});// Leader portrait (displayed in diplomacy screens)const leaderPortrait = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/leader-portrait.png', name: 'leader_custom'});// Unit icon (displayed in the unit panel)const unitIcon = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/unit-icon.png', name: 'unit_icon_custom'});// Building icon (displayed in city production panel)const buildingIcon = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/building-icon.png', name: 'building_icon_custom'});// Tradition icon (displayed in tradition tree)const traditionIcon = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/tradition-icon.png', name: 'tradition_icon_custom'});// Add all assets to modmod.add([civIcon, leaderPortrait, unitIcon, buildingIcon, traditionIcon]);
// Sound effectconst soundEffect = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/custom-sound.wav', name: 'sound_custom'});// 3D model (if supported by the game)const modelAsset = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: './assets/custom-model.glb', name: 'model_custom'});// Add to modmod.add([soundEffect, modelAsset]);
Assets and icons are essential elements that bring your mod to life visually. By following the guidelines in this guide, you can create professional-looking mods with custom assets that enhance the player experience. Remember to keep asset files organized and use consistent naming conventions to make your mod development process smoother.