Generates the unique ids assigned to table keys.
A collection's SharedTableData asks its generator for a new id whenever a key is added, and the id
stays with that key for its lifetime. The default implementation is DistributedUIDGenerator, which
produces non-sequential ids so several users can add keys without collisions. Implement this interface to supply a
different scheme, then assign it through SharedTableData.KeyGenerator.
Additional resources: DistributedUIDGenerator, SharedTableData
<para>A simple generator that hands out increasing ids.</para>
using Unity.Localization; using UnityEngine;
namespace Unity.Localization.Samples { public class IKeyGeneratorExample : IKeyGenerator { long m_Next = 1;
public long GetNextKey() => m_Next++;
public static void Use() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); sharedData.KeyGenerator = new IKeyGeneratorExample();
SharedTableData.SharedTableEntry entry = sharedData.AddKey("GREETING");
Debug.Log(entry.Id); // 1 } } }
| Method | Description |
|---|---|
| GetNextKey | Returns the next id to assign to a key. |