By default Glue creates a new class in the DataTypes namespace for every CSV in your project. For example, if you create two CSVs called Map1.csv and Map2.csv, then you will get two classes:
Many games use multiple CSV files to organize data that fits in the same category – such as the placement of enemies in multiple levels. In other words, Map1 and Map2 may contain the exact same properties. In this case, you would want both Map1.csv and Map2.csv to load into the same type. For example a class called MapInfo.
The “Set Created Class” right-click menu item allows you to set the class that a CSV creates and allows multiple CSVs to share the same class.
For this example we’ll start with two CSV files: Level1.csv and Level2.csv. By default these two CSVs are creating two classes: Level1 and Level2. We’ll modify the Glue project so that both use a class LevelLayout.
- First start with two CSV files
- Right-click on the first CSV and select “Set Created Class”
- Click “New Class”
- Enter the name “LevelLayout” and click OK
- Highlight “LevelLayout” and click “Use This Class”
- If asked whether to remove unused file, click “Yes”
- You should now see that Level1.csv uses the LevelLayout class
- Click “Done”
- Repeat the above steps for Level2.csv (of course, reuse LevelLayout instead of creating a new class)
Now both Level1 and Level2 will use the LevelLayout class.