Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

FileTableProviderEditor

class in Unity.Localization.Editor

/

Inherits from:Unity.Localization.Editor.AssetProviderEditor

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

Cancel

Description

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

Properties

Property Description
Writer The writer that turns a table snapshot into the provider's file format.

Public Methods

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.

Inherited Members

Public Methods

MethodDescription
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.

Protected Methods

MethodDescription
RegisterTable Registers a single per-locale table with the provider.
UnregisterTable Removes a single per-locale table from the provider.

Static Methods

MethodDescription
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.