IKeyGenerator
Generates the unique ids assigned to table keys.
Read time 1 minuteLast updated 7 days ago
Definition
- Type: Interface
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
public interface IKeyGenerator
Remarks
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
A simple generator that hands out increasing ids.
Examples
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 } }}
Methods
Method | Description |
|---|---|
| GetNextKey | Returns the next id to assign to a key. |