# IVariantSelector

> Picks which variant key applies right now, for example the current platform, storefront, or gender.

## Definition

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

```csharp
public interface IVariantSelector
```

## Remarks

A variant-driven key holds one value per key the selector can report, and resolution returns the value whose key equals [IVariantSelector.CurrentKey](/engine/6000.7/script-reference/unity/localization/ivariantselector/currentkey.md). Keys are free-form strings, so a selector can model anything: the built-in platform selector reports the current [\_platform](/engine/6000.7/script-reference/unityengine/application/platform.md), and a custom selector can report a storefront, a day of the week, or a player choice instead. Implement the interface on one serializable class with a public parameterless constructor; the Localization Tables window's selector picker skips types without one, and loading file-based tables recreates selectors with it. The implementation appears in the picker automatically, and its [IVariantSelector.AvailableKeys](/engine/6000.7/script-reference/unity/localization/ivariantselector/availablekeys.md) fill the window's Add Variant menu.

Additional Resources: [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md), [SharedTableData](/engine/6000.7/script-reference/unity/localization/sharedtabledata.md)

A selector that varies text by storefront, for builds that ship on more than one store per platform.

```csharp
using System;
using System.Collections.Generic;

namespace Unity.Localization.Samples
{
 // Varies text by store rather than platform, for a game that ships on Steam and GOG.
 [Serializable]
 public class StorefrontVariantSelector : IVariantSelector
 {
 // Set once by the game's boot code, for example from a build define or launcher detection.
 public static string CurrentStorefront = "Steam";

 public string SelectorId => "storefront";

 public string CurrentKey => CurrentStorefront;

 public IEnumerable<string> AvailableKeys => new[] { "Steam", "GOG" };
 }
}
```

A selector that combines the two: storefront keys where a storefront is known, platform keys everywhere else.

```csharp
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Unity.Localization.Samples
{
 // Combines platform and storefront keys: storefront variants win where a storefront is known,
 // and every other platform resolves through Unity's platform names as usual.
 [Serializable]
 public class PlatformOrStorefrontSelector : IVariantSelector
 {
 // Set by the game's boot code on PC; left null elsewhere.
 public static string Storefront;

 public string SelectorId => "platform-storefront";

 public string CurrentKey => Storefront ?? Application.platform.ToString();

 public IEnumerable<string> AvailableKeys
 {
 get
 {
 foreach (var platform in Enum.GetNames(typeof(RuntimePlatform)))
 yield return platform;
 yield return "Steam";
 yield return "GOG";
 }
 }
 }
}
```

## Properties

| Property                                                                                              | Description                                                  |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [AvailableKeys](/engine/6000.7/script-reference/unity/localization/ivariantselector/availablekeys.md) | Every key this selector can report.                          |
| [CurrentKey](/engine/6000.7/script-reference/unity/localization/ivariantselector/currentkey.md)       | The variant key that applies to the current runtime context. |
| [SelectorId](/engine/6000.7/script-reference/unity/localization/ivariantselector/selectorid.md)       | Stable identifier for this selector kind.                    |
