Usage Example: Build City Assets and Scene Objects from CSV
May 18, 2026 · View on GitHub
This example shows how an agent can take a multi-step Unity task, generate the required scripts, import structured data, create assets, update the active scene, and verify the result.

What this example demonstrates
- Creating Unity scripts from a prompt
- Importing CSV data into ScriptableObject assets
- Building scene content automatically in the active scene
- Reusing existing project assets such as sprites
- Validating the final scene state after the changes
User prompt
Add following feature to Unity using execute script tool:
- Read cities list from csv file #file:cities.csv
- Create CitySO ScriptableObject class with properties based on csv columns, place it in Assets/Scripts/ScriptableObjects
- Create assets for each city in the csv file, populate properties with data from the file, place them in Assets/ScriptableObjects
- Create CityComponent MonoBehaviour class with a reference to CitySO ScriptableObject and place it in Assets/Scripts
- Create Map root gameobject in the current scene
- For each city asset, create a City gameobject as a child of Map, set its position based on the coordinates from the asset, add CityComponent and assign the corresponding CitySO asset
- To each City gameObject add SpriteRenderer component and assign a default sprite from Assets/Images/City.png
Outcome
The agent completed the full "cities from CSV to scene" workflow.
- Added
CitySOScriptableObject:CitySO.cs - Added
CityComponentMonoBehaviour:CityComponent.cs - Added the CSV data file:
cities.csv - Ran an Editor execution script that:
- Created 49
CitySOassets inAssets/ScriptableObjects - Created a
Maproot GameObject in the active scene with 49Citychildren - Set each city position from
Coordinates - Added
CityComponentand assigned the matchingCitySO - Added
SpriteRendererand assigned the default sprite fromCity.png
- Created 49
Transcript
Used ChatGPT 5.2
User
Add following feature to Unity using execute script tool:
- Read cities list from csv file #file:cities.csv
- Create CitySO ScriptableObject class with properties based on csv columns, place it in Assets/Scripts/ScriptableObjects
- Create assets for each city in the csv file, populate properties with data from the file, place them in Assets/ScriptableObjects
- Create CityComponent MonoBehaviour class with a reference to CitySO ScriptableObject and place it in Assets/Scripts
- Create Map root gameobject in the current scene
- For each city asset, create a City gameobject as a child of Map, set its position based on the coordinates from the asset, add CityComponent and assign the corresponding CitySO asset
- To each City gameObject add SpriteRenderer component and assign a default sprite from Assets/Images/City.png
GitHub Copilot
I’m going to (1) locate or add cities.csv, (2) add the CitySO + CityComponent scripts in the requested folders, then (3) run a Unity Editor script to import the CSV, create the ScriptableObject assets, and build the Map + City GameObjects with sprite renderers in the current scene.
- Searched for files matching
**/cities.csv, 1 match - Read Assets
- Searched for files matching
**/Assets/**/City.png*, no matches - Read Assets/Images
- Read Assets/Plugins/UnityCodeMcpServer/Documentation~/Examples/cities.csv
- Created Assets/Scripts/ScriptableObjects/CitySO.cs
- Created Assets/Scripts/CityComponent.cs
- Created Assets/Resources/cities.csv
Next I’ll run a Unity Editor execution script that imports cities.csv, creates or updates CitySO assets in Assets/ScriptableObjects, and builds the Map + City GameObjects with CityComponent and SpriteRenderer in the current scene.
- Ran
execute_csharp_script_in_unity_editor
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
static class CitiesImporter
{
private const string CsvAssetPath = "Assets/Resources/cities.csv";
private const string CityAssetsFolder = "Assets/ScriptableObjects";
private const string DefaultSpritePath = "Assets/Images/City.png";
public static object Run()
{
AssetDatabase.Refresh();
var start = DateTime.UtcNow;
while (EditorApplication.isCompiling)
{
if ((DateTime.UtcNow - start).TotalSeconds > 60)
throw new Exception("Unity is still compiling after 60s. Re-run the script once compilation finishes.");
System.Threading.Thread.Sleep(200);
}
var citySoType = typeof(CitySO);
var cityComponentType = typeof(CityComponent);
EnsureFolder(CityAssetsFolder);
// ... rest of import utility omitted for brevity
}
return CitiesImporter.Run();
Full script: CitiesImporter.cs
- Checked Assets/Scripts/ScriptableObjects/CitySO.cs and Assets/Scripts/CityComponent.cs, no problems found
- Read Assets/ScriptableObjects
- Ran
execute_csharp_script_in_unity_editor
using UnityEngine;
using UnityEngine.SceneManagement;
var scene = SceneManager.GetActiveScene();
GameObject map = null;
foreach (var root in scene.GetRootGameObjects())
{
if (root != null && root.name == "Map")
{
map = root;
break;
}
}
if (map == null)
return "Map not found in active scene.";
return $"Map found. Child count: {map.transform.childCount}.";
Implemented the full "cities from CSV to scene" pipeline.
- Added
CitySOScriptableObject:CitySO.cs - Added
CityComponentMonoBehaviour:CityComponent.cs - Added the CSV data file:
cities.csv - Ran an Editor execution script that:
- Created 49
CitySOassets inAssets/ScriptableObjects - Created a
Maproot GameObject in the active scene with 49Citychildren - Set each city position from
Coordinates, addedCityComponentand assigned the matchingCitySO - Added
SpriteRendererto each city and assigned the default sprite fromCity.png
- Created 49