Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


FileTableProviderEditor

The editor half of a file-backed content source, supplying the writer that generates its table files.
Read time 2 minutesLast updated 12 days ago

Definition

public abstract class FileTableProviderEditor : AssetProviderEditor

Remarks

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
Register a writer for a custom file format.

Examples

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; }}

Properties

Property

Description

WriterThe writer that turns a table snapshot into the provider's file format.

Methods

Method

Description

ClearRegistrationsDrops every collection the provider records.
RegisterCollectionRecords a collection so the provider serves its table files at runtime.
UnregisterCollectionDrops a collection so the provider stops serving its table files.

Inheritance