本地化问题修改
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Components;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
[RequireComponent(typeof(TMP_Text))]
|
||||
[RequireComponent(typeof(LocalizeStringEvent))]
|
||||
public class LocalizedText : MonoBehaviour
|
||||
{
|
||||
private TMP_Text _text;
|
||||
private LocalizeStringEvent _localizeEvent;
|
||||
|
||||
private void OnUpdateString(string text)
|
||||
{
|
||||
var textArr = text.Split(":");
|
||||
_text.text = textArr.Length > 1 ? textArr[1].Trim() : text;
|
||||
}
|
||||
|
||||
public void SetLocalizedText(string table, string entry)
|
||||
{
|
||||
_text = GetComponent<TMP_Text>();
|
||||
_localizeEvent = GetComponent<LocalizeStringEvent>();
|
||||
|
||||
_localizeEvent.OnUpdateString.AddListener(OnUpdateString);
|
||||
|
||||
_localizeEvent.SetTable(table);
|
||||
_localizeEvent.SetEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c9c71a7e9c9455d955ff20b5db823a1
|
||||
timeCreated: 1746702086
|
||||
@@ -7,24 +7,36 @@ using AibisDream.Utility;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Components;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class TaskPanel : MonoBehaviour, IUIPanel, IDialogView
|
||||
{
|
||||
private RectTransform _rectTransform;
|
||||
private Transform _taskListParent;
|
||||
private GameObject _taskItemPrefab;
|
||||
|
||||
private readonly Dictionary<string, GameObject> _taskDict = new();
|
||||
private GameObject TaskItemPrefab
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_taskItemPrefab == null)
|
||||
{
|
||||
_taskItemPrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.TaskItemName);
|
||||
}
|
||||
|
||||
return _taskItemPrefab;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, LocalizedText> _taskDict = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
_taskListParent = transform.Find("Record");
|
||||
_taskItemPrefab = ResourceKit.LoadAddressableSync<GameObject>(ConstRef.TaskItemName);
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, ClearTasks);
|
||||
DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Task, this);
|
||||
}
|
||||
|
||||
#region 诊疗单功能
|
||||
@@ -33,7 +45,9 @@ namespace AibisDream
|
||||
{
|
||||
if (_taskDict.TryGetValue(lineId, out var taskItem))
|
||||
{
|
||||
taskItem.GetComponent<TMP_Text>().fontStyle |= FontStyles.Strikethrough;
|
||||
var taskText = taskItem.GetComponent<TMP_Text>();
|
||||
taskText.fontStyle |= FontStyles.Strikethrough;
|
||||
taskText.color = Color.gray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +66,15 @@ namespace AibisDream
|
||||
|
||||
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
|
||||
{
|
||||
var taskItem = Instantiate(_taskItemPrefab, _taskListParent);
|
||||
var taskItem = Instantiate(TaskItemPrefab, _taskListParent);
|
||||
// 设置本地化数据
|
||||
var localize = taskItem.GetComponent<LocalizeStringEvent>();
|
||||
localize.SetTable(DialogController.Instance.GetCurLocalizedTableName());
|
||||
localize.SetEntry(lineId);
|
||||
_taskDict[lineId] = taskItem;
|
||||
|
||||
ActionKit.Delay(0.5f, nextStep);
|
||||
var localize = taskItem.GetComponent<LocalizedText>();
|
||||
localize.SetLocalizedText(DialogController.Instance.GetCurLocalizedTableName(), lineId);
|
||||
_taskDict[lineId] = localize;
|
||||
|
||||
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
|
||||
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
|
||||
nextStep.Invoke();
|
||||
}
|
||||
|
||||
public void ShowOptions(DialogOption[] dialogueOptions)
|
||||
@@ -85,7 +100,6 @@ namespace AibisDream
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 打开和关闭
|
||||
|
||||
public bool IsOpen { get; private set;}
|
||||
@@ -95,7 +109,7 @@ namespace AibisDream
|
||||
gameObject.SetActive(true);
|
||||
AudioManager.Instance.PlaySfx("event:/Scriptal/taskmanager");
|
||||
// 下移
|
||||
transform.DOLocalMoveY(-350, 1f).OnComplete(() =>
|
||||
_rectTransform.DOAnchorPosY(-350, 1f).OnComplete(() =>
|
||||
{
|
||||
IsOpen = true;
|
||||
});
|
||||
@@ -105,7 +119,7 @@ namespace AibisDream
|
||||
{
|
||||
// 上移
|
||||
AudioManager.Instance.PlaySfx("event:/Scriptal/taskmanager");
|
||||
transform.DOLocalMoveY(0, 1f).OnComplete(() =>
|
||||
_rectTransform.DOAnchorPosY(0, 1f).OnComplete(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
IsOpen = false;
|
||||
@@ -117,7 +131,7 @@ namespace AibisDream
|
||||
|
||||
public static class TaskYarnCommand
|
||||
{
|
||||
private static TaskPanel TaskPanel => UIManager.Instance.GetComponent<TaskPanel>();
|
||||
private static TaskPanel TaskPanel => UIManager.Instance.GetPanel<TaskPanel>();
|
||||
|
||||
[YarnCommand("complete_task")]
|
||||
public static void CompleteTask(string lineId)
|
||||
|
||||
Reference in New Issue
Block a user