Files
VFSUnity/Assets/TextMesh Pro/Examples & Extras/Scripts/ChatController.cs
T
yangbear 2d0aaa98aa fix: 修复 UI 导航流程,添加 Debug.Log 完整日志
- 重写 PageController.cs,为所有按钮回调添加完整 Debug.Log
- 自动修复 _btnFixationBack:未赋值时自动查找 FixationPanel/BtnBack
- 自动修复 _btnExperimentBack:未赋值时自动查找 ExperimentPanel/Navbar/BtnBack
- 删除失效的 Canvas 根级冗余 BtnFixationBack
- 添加 3D 角色模型资源(man/woman 模型、动画、TextMesh Pro)
- 添加 ExperimentPanel UI 资源和 TrainingBackground 素材

测试方法:进入 Play 模式,查看 Console 以验证每个按钮的绑定状态和点击回调是否正常触发。
2026-06-27 13:25:58 +08:00

52 lines
1.3 KiB
C#
Executable File

using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ChatController : MonoBehaviour {
public TMP_InputField ChatInputField;
public TMP_Text ChatDisplayOutput;
public Scrollbar ChatScrollbar;
void OnEnable()
{
ChatInputField.onSubmit.AddListener(AddToChatOutput);
}
void OnDisable()
{
ChatInputField.onSubmit.RemoveListener(AddToChatOutput);
}
void AddToChatOutput(string newText)
{
// Clear Input Field
ChatInputField.text = string.Empty;
var timeNow = System.DateTime.Now;
string formattedInput = "[<#FFFF80>" + timeNow.Hour.ToString("d2") + ":" + timeNow.Minute.ToString("d2") + ":" + timeNow.Second.ToString("d2") + "</color>] " + newText;
if (ChatDisplayOutput != null)
{
// No special formatting for first entry
// Add line feed before each subsequent entries
if (ChatDisplayOutput.text == string.Empty)
ChatDisplayOutput.text = formattedInput;
else
ChatDisplayOutput.text += "\n" + formattedInput;
}
// Keep Chat input field active
ChatInputField.ActivateInputField();
// Set the scrollbar to the bottom when next text is submitted.
ChatScrollbar.value = 0;
}
}