🚀 Quickstart: Your First Implementation
Step 0: Assemblies
If your project uses Assembly Definitions, your scripts won’t be able to “see” the CSV Suite by default. Navigate to your project’s .asmdef file and add a reference to Canley.Utility.CSV. This “unlocks” the namespace so you can call using Canley.Utility.CSV;
1. Setup the Manager
- Attach the
CanleyCSVManagercomponent to a GameObject. - Drag your
.csvfile into the Target File slot in the Inspector. - Configure Trim Whitespace or Auto Pad Columns as needed.
2. Read Data
Access your data easily via the Manager’s Reader. The GetCell method ensures no “Index Out of Range” crashes:
using Canley.Utility.CSV;
// Get a specific cell safely (returns string.Empty if out of bounds)
string playerName = csvManager.Reader.GetCell(1, 0);
// Find a column by its header name
int scoreIndex = csvManager.Reader.GetHeaderIndex("Score");3. Save Data (Persistent)
Save user-generated content safely to the device’s local storage. The SaveToFile method returns a bool so you can handle errors gracefully:
string csvString = CanleyCSVWriter.Export(myDataList);
if (csvManager.SaveToFile("PlayerData.csv", csvString)) {
Debug.Log("Save Successful!");
}4. Remote Data & Live Updates
Inject raw CSV strings (from a UnityWebRequest or an API) directly into the manager without needing to save them to disk first:
// Inject raw text directly into the engine
csvManager.ParseRawData(myDownloadHandler.text);