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 T at runtime using ScriptableObject.CreateInstance and adds it to the table’s internal collection.

  • Workflow:

    1. Instantiation: Creates the ScriptableObject record in memory and assigns the specified label.
    2. Identifier Assignment: Computes and assigns a unique integer ID based on the configured idType setting (either a deterministic hash from the label or a random UUID).
    3. Registration: Appends the new record instance to the active Records list.
  • 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 SaveTable after creating records dynamically if you want those runtime additions written out to your persistent data files.