DistributedUIDGenerator
Creates a generator that measures timestamps from the default epoch.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Constructor
- Namespace: Unity.Localization
- Assembly: UnityEngine.LocalizationRuntimeModule
DistributedUIDGenerator()
Creates a generator that measures timestamps from the default epoch.
public DistributedUIDGenerator()
Remarks
The DistributedUIDGenerator.CustomEpoch is 2020-01-01T00:00:00Z, shared by every generator built this way. Use the DistributedUIDGenerator overload to measure from a different point instead.
Assign a default generator to a collection's shared data.
Examples
using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class DistributedUIDGeneratorConstructorExample { public void Run() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); sharedData.KeyGenerator = new DistributedUIDGenerator(); SharedTableData.SharedTableEntry entry = sharedData.AddKey("GREETING"); Debug.Log(entry.Id != 0); // True } }}
DistributedUIDGenerator(long)
Creates a generator that measures timestamps from a specific epoch.
public DistributedUIDGenerator(long customEpoch)
Parameters
The epoch, in Unix milliseconds, that timestamps are measured from.
Remarks
The timestamp portion of each id counts from instead of the default epoch, which takes the generator off the timeline the default generators share, so its ids can collide with theirs. For that reason a generator restored from a saved SharedTableData reverts to the default epoch, and an epoch set here lasts only for the life of the instance.
customEpochCreate a generator pinned to a fixed epoch.
Examples
using System;using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class DistributedUIDGeneratorCustomEpochExample { public void Run() { var epoch = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero).ToUnixTimeMilliseconds(); var generator = new DistributedUIDGenerator(epoch); Debug.Log(generator.CustomEpoch == epoch); // True } }}