Detailed Method Reference
Namespace: Canley.Utility.CSV.Standard
Class: CSVTable<T>
Definition
public T CreateRecord(string label = "New Record")-
Description: Instantiates a new record instance of type
Tat runtime usingScriptableObject.CreateInstanceand adds it to the table’s internal collection. -
Workflow:
- Instantiation: Creates the ScriptableObject record in memory and assigns the specified label.
- Identifier Assignment: Computes and assigns a unique integer ID based on the configured
idTypesetting (either a deterministic hash from the label or a random UUID). - Registration: Appends the new record instance to the active
Recordslist.
-
Parameters:
label: The human-friendly string label or slug assigned to the new record (defaults to"New Record").
-
Returns:
T- The newly created and initialised record instance. -
Example:
public void AddNewWeapon(CSVTable<WeaponRecord> weaponTable)
{
WeaponRecord sword = weaponTable.CreateRecord("Steel_Sword");
sword.damage = 50;
Debug.Log(message: $"Generated ID: {sword.id}");
}TIP
Ensure you call
SaveTableafter creating records dynamically if you want those runtime additions written out to your persistent data files.