Documentation

Unity Engine

Download Unity

Unity Engine

CreateCollection(string, string)

Creates a table collection with one table for each available locale.
Read time 1 minuteLast updated 6 hours ago

Definition

public static ResourceTableCollection CreateCollection(string parentFolder, string collectionName)

Parameters

parentFolder

The project-relative path of an existing folder, for example
Assets/Localization
.

collectionName

The name of the collection and of the folder that holds it.

Returns

Type

Description

ResourceTableCollectionThe new ResourceTableCollection, or
null
when it could not be created.

Remarks

Creates a folder named
collectionName
inside
parentFolder
that holds the ResourceTableCollection asset, its SharedTableData asset, and a ResourceTable asset for each locale in the LocalizationSettings.AvailableLocales of LocalizationEditorSettings.ActiveSettings. A numeric suffix is added to any name that is already taken, so read the name back from the returned collection. A collection inside a Resources folder uses the Resources content source; otherwise it uses the content source that the Project Settings choose. The collection is registered with that source and saved. The call does nothing and returns
null
when the project has no LocalizationEditorSettings.ActiveSettings or those settings have no locale.
Creates a collection in the Assets/Localization folder and adds a key to it.

Examples

using Unity.Localization.Editor;using UnityEditor;namespace Unity.Localization.Samples{ public class CreateCollectionExample { public void Run() { if (!AssetDatabase.IsValidFolder("Assets/Localization")) AssetDatabase.CreateFolder("Assets", "Localization"); var collection = LocalizationEditorSettings.CreateCollection("Assets/Localization", "Menu"); if (collection == null) return; LocalizationEditorSettings.CreateStringEntry(collection, "Play"); } }}