您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
30 行
1.2 KiB
30 行
1.2 KiB
using UnityEngine;
|
|
using UnityEngine.Localization;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
namespace UnityEditor.Localization.Samples
|
|
{
|
|
/// <summary>
|
|
/// This example shows how to use GetLocalizedString to retrieve a localized string.
|
|
/// </summary>
|
|
public class LocalizedStringGetLocalizedStringExample : MonoBehaviour
|
|
{
|
|
// A LocalizedString provides an interface to retrieving translated strings.
|
|
// This example assumes a String Table Collection with the name "My String Table" and an entry with the Key "Hello World" exists.
|
|
// You can change the Table Collection and Entry target in the inspector.
|
|
public LocalizedString stringRef;
|
|
void OnGUI()
|
|
{
|
|
|
|
// This will make a request to the StringDatabase each time using the LocalizedString properties.
|
|
var stringOperation = stringRef.GetLocalizedString();
|
|
if (stringOperation.IsDone && stringOperation.Status == AsyncOperationStatus.Succeeded)
|
|
GUILayout.Label(stringOperation.Result);
|
|
}
|
|
private void Start()
|
|
{
|
|
stringRef = new LocalizedString() { TableReference = "QuestlineDialogue", TableEntryReference = "SD-L1-S1-Q1-QL1" };
|
|
|
|
}
|
|
}
|
|
}
|