DistributedUIDGenerator
class in
Unity.Localization
Implements interfaces:IKeyGenerator
Suggest a change
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close
Description
The default key generator. It produces a distributed unique id, Snowflake-style, that combines a timestamp, a
machine id, and a per-millisecond sequence.
using Unity.Localization;
using UnityEngine;
namespace Unity.Localization.Samples
{
public class DistributedUIDGeneratorOverviewExample
{
public void Run()
{
var generator = new DistributedUIDGenerator();
var first = generator.GetNextKey();
var second = generator.GetNextKey();
Debug.Log(first != second); // True: ids are unique
}
}
}
Properties
| Property |
Description |
| CustomEpoch |
The epoch, in Unix milliseconds, that timestamps are measured from.
|
| MachineId |
The machine id folded into each id.
|
Constructors
| Constructor |
Description |
| DistributedUIDGenerator |
Creates a generator that measures timestamps from the current time.
|
Public Methods
| Method |
Description |
| GetNextKey |
Returns the next distributed unique id.
|