CSVRecord

Namespace: Canley.Utility.CSV.Standard
Base Class: ScriptableObject

Overview

The CSVRecord class is a ScriptableObject representing a single row of data within your CSV table. It serves a dual purpose in your game architecture: acting as a strongly-typed live C# data class for runtime logic, while maintaining a background Shadow Dictionary (rawValues) to ensure 100% data preservation.

By bridging the gap between raw spreadsheet strings and high-level Unity objects, it allows developers to handle complex assets, custom formats, and unmapped columns without risking data loss during round-trip saves.


Property Reference

ClassMember (Syntax)Description
CSVRecordidThe unique integer identifier used for high-performance lookups.
CSVRecordrecordLabelThe human-friendly string slug used for identification and deterministic ID generation.
CSVRecordrawValuesThe internal Shadow Dictionary storing raw string data for unmapped columns.
CSVRecordthis[string fieldName]Indexer providing direct read/write access to the Shadow Dictionary.

Method Reference

ClassMember (Syntax)Description
CSVRecordGetRaw(string fieldName)Returns the raw string value for any specified column, returning null if missing.
CSVRecordInitialize(string label, int explicitId)Manually sets the record identity, generating a deterministic hash if the ID is zero.
CSVRecordOnImportField(string fieldName, string rawValue)Virtual inbound hook for intercepting and transforming raw strings during hydration (e.g., loading Sprites).
CSVRecordOnExportField(string fieldName, string currentValue)Virtual outbound hook for sanitising or formatting data right before writing back to disk.

Key Features

  • Shadow Dictionary Preservation: Any column present in your spreadsheet that lacks a matching public variable in your C# class is safely retained in the background, preventing data destruction during table saves.
  • Asset Bridging: Using the OnImportField override, you can easily map string identifiers (like filenames) to heavy Unity assets such as Sprites or AudioClips via Resources.Load.
  • Flexible Identification: Supports both deterministic hash-based integer IDs derived from your record slug and randomized UUID configurations.

NOTE

Always ensure that your custom CSV record classes inherit from CSVRecord and are marked with the [Serializable] attribute so the reflection engine can properly map your public fields.

0 items under this folder.