Pardon our dust! Docs for Yarn Spinner for Unity 3.2 and Yarn Spinner for Godot C# are on docs.yarnspinner.dev (the old docs site). Docs for Yarn Spinner for Unity 3.3 (pre-release, out ASAP), Yarn Spinner for Godot GDScript and Yarn Spinner for Unreal Engine (work in progress) are on /docs/ (the new docs site).

Localization

A localization is a bundle of strings and assets for a particular culture
public class Localization : ScriptableObject

Inherits from ScriptableObject

#Nested Types

#Properties

#UsesAddressableAssets

Gets a value indicating whether this Localization makes use of Addressable Assets (true), or if it stores its assets as direct references (false).
public bool UsesAddressableAssets { get; internal set; }

Type Boolean

If this property is true, GetLocalizedObjectAsync<T>(string) and ContainsLocalizedObject<T>(string) should not be used to retrieve localised objects. Instead, the Addressable Assets API should be used.

#Methods

#AddLocalizedString(string, string)

Adds a new string to the runtime string table.
public void AddLocalizedString(string key, string value)

Parameters

  • keystring
    The key for this string (generally, the line ID.)
  • valuestring
    The user-facing text for this string, in the language specified by LocaleCode.
This method updates the localisation's runtime string table, which is useful for adding or changing the localisation during gameplay or in a built player. It doesn't modify the asset on disk, and any changes made will be lost when gameplay ends.

#AddLocalizedStrings(IEnumerable<KeyValuePair<string, string>>)

Adds a collection of strings to the runtime string table.
public void AddLocalizedStrings(IEnumerable<KeyValuePair<string, string>> strings)

Parameters

  • stringsIEnumerable<KeyValuePair<string, string>>
    The collection of keys and strings to add.
This method updates the localisation's runtime string table, which is useful for adding or changing the localisation during gameplay or in a built player. It doesn't modify the asset on disk, and any changes made will be lost when gameplay ends.

#AddLocalizedStrings(IEnumerable<StringTableEntry>)

Adds a collection of strings to the runtime string table.
public void AddLocalizedStrings(IEnumerable<StringTableEntry> stringTableEntries)

Parameters

  • strings(unknown)
    The collection of StringTableEntry objects to add.
  • stringTableEntriesIEnumerable<Yarn.Unity.StringTableEntry>
This method updates the localisation's runtime string table, which is useful for adding or changing the localisation during gameplay or in a built player. It doesn't modify the asset on disk, and any changes made will be lost when gameplay ends.

#Clear()

Removes all entries from the localisation
public virtual void Clear()

#ContainsLocalizedObject<T>(string)

Checks if there is a localised asset of the requested type for the requested line
public bool ContainsLocalizedObject<T>(string key)
    where T : UnityEngine.Object;

Type Parameters

  • T
    The expected asset type

Parameters

  • keystring
    the id of the localised line

Returns Boolean: true if there is an asset of the requested type under the requested key, false otherwise.

#ContainsLocalizedString(string)

Returns a boolean value indicating whether this Localization contains a string with the given key.
public bool ContainsLocalizedString(string key);

Parameters

  • keystring
    The key to search for.

Returns Boolean: true if this Localization has a string for the given key; false otherwise.

#GetLineIDs()

Gets the line IDs present in this localization.
public IEnumerable<string> GetLineIDs()

Returns IEnumerable: The line IDs.

The line IDs can be used to access the localized text or asset associated with a line.

#GetLocalizedObjectAsync<T>(string)

Attempts to load an asset for the localised line.
public async YarnTask<T?> GetLocalizedObjectAsync<T>(string key)
    where T : UnityEngine.Object

Type Parameters

  • T
    The expected type of the asset

Parameters

  • keystring
    the line id of the localised entry whos asset you're after

Returns YarnTask: The localised asset, or null if there wasn't one found

This method does not take in a cancellation token because there is no mechanism to pass it through to the underlying addressables load request

#GetLocalizedString(string)

public string? GetLocalizedString(string key)

Parameters

  • keystring

Returns String

Generated from Yarn Spinner for Unity 3.3.