class in Unity.Localization.Editor
/
Inherits from:Unity.Localization.Editor.AssetProviderEditor
The editor half of a file-backed content source, supplying the writer that generates its table files.
A FileTableProvider reads tables from files at runtime, and this generates those files when player
data is built. Subclass it, return a writer matching the provider's reader, and register it with an
AssetProviderEditorAttribute naming the provider type. Without a registered editor the provider's
files are never generated and its tables do not resolve in a player.
Additional resources: ITableFileWriter, FileTableProvider
<para>Register a writer for a custom file format.</para>
using System.IO; using System.Text; using Unity.Localization.Editor; using Unity.Localization.Providers.FileTables;
namespace Unity.Localization.Samples { public class TextTableWriter : ITableFileWriter { public static readonly TextTableWriter Instance = new();
public void Write(ResourceTableData data, Stream stream) { using var writer = new StreamWriter(stream, new UTF8Encoding(false), 1024, leaveOpen: true); writer.WriteLine($"@collection={data.CollectionName}"); writer.WriteLine($"@guid={data.CollectionGuid}"); writer.WriteLine($"@locale={data.LocaleCode}"); foreach (var entry in data.Entries) { if (entry != null && !string.IsNullOrEmpty(entry.Key)) writer.WriteLine($"{entry.Key}={entry.Value}"); } } }
// Registering the editor for the provider type is what makes Unity generate the files at build time. [AssetProviderEditor(typeof(TextResourceProvider))] public class TextResourceProviderEditor : FileTableProviderEditor { public override ITableFileWriter Writer => TextTableWriter.Instance; } }
| Property | Description |
|---|---|
| Writer | The writer that turns a table snapshot into the provider's file format. |
| Method | Description |
|---|---|
| ClearRegistrations | Drops every collection the provider records. |
| RegisterCollection | Records a collection so the provider serves its table files at runtime. |
| UnregisterCollection | Drops a collection so the provider stops serving its table files. |
| Method | Description |
|---|---|
| ClaimsPath | Returns whether this provider should serve a collection saved at a given path. |
| CreateReference | Creates the table reference to store when a collection is assigned to a localized reference. |
| EnumerateCollections | Returns the collections assigned to a provider. |
| SetLocaleEnabled | Adds or removes a locale's tables across the provider's collections when the locale is toggled. |
| Method | Description |
|---|---|
| RegisterTable | Registers a single per-locale table with the provider. |
| UnregisterTable | Removes a single per-locale table from the provider. |
| Method | Description |
|---|---|
| GuidTableAddress | Returns the address a per-locale table is served under, keyed by the collection guid. |
| TableAddress | Returns the address a per-locale table is served under, keyed by collection name. |