Glue:Reference:Files:Set Created Class

Introduction

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:

  1. Map1
  2. Map2

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.

Example

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.

  1. First start with two CSV filesTwoCsvs.png
  2. Right-click on the first CSV and select “Set Created Class”RightClickSetCreatedClass.png
  3. Click “New Class”ClickNewClass.png
  4. Enter the name “LevelLayout” and click OKEnterLevelLayoutName.png
  5. Highlight “LevelLayout” and click “Use This Class”HighlightClickUseThisClass.png
  6. If asked whether to remove unused file, click “Yes”
  7. You should now see that Level1.csv uses the LevelLayout classLevelLayoutUsed.png
  8. Click “Done”
  9. Repeat the above steps for Level2.csv (of course, reuse LevelLayout instead of creating a new class)BothUsingSameClass.png

Now both Level1 and Level2 will use the LevelLayout class.

Additional Information