# DistributedUIDGenerator

> Creates a generator that measures timestamps from the current time.

## Definition

* **Type:** Constructor
* **Namespace:** [Unity.Localization](/engine/6000.7/script-reference/unity/localization.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule

## DistributedUIDGenerator()

Creates a generator that measures timestamps from the current time.

```csharp
public DistributedUIDGenerator()
```

### Remarks

The current UTC time becomes the [DistributedUIDGenerator.CustomEpoch](/engine/6000.7/script-reference/unity/localization/distributeduidgenerator/customepoch.md). Use the [DistributedUIDGenerator](/engine/6000.7/script-reference/unity/localization/distributeduidgenerator/ctor.md) overload to pin the epoch to a fixed point instead.

Assign a default generator to a collection's shared data.

### Examples

```csharp
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.

```csharp
public DistributedUIDGenerator(long customEpoch)
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The epoch, in Unix milliseconds, that timestamps are measured from.

### Remarks

Because the timestamp portion of each id counts from `customEpoch`, a later epoch keeps ids smaller for longer before the 41-bit timestamp range is exhausted.

Create a generator pinned to a fixed epoch.

### Examples

```csharp
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
        }
    }
}
```
