这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

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