FM/Assets/Scripts/Base/MonoBehaviour/UpdateInputField.cs

33 lines
848 B
C#

using System;
using TMPro;
using UnityEngine;
namespace HK
{
public class UpdateInputField : MonoBehaviour
{
TMP_InputField targetInputField;
TMP_InputField inputField;
private void Awake()
{
inputField = GetComponent<TMP_InputField>();
}
public void SetData(TMP_InputField target)
{
targetInputField = target;
}
private void Update()
{
if (inputField == null || targetInputField == null) return;
inputField.text = targetInputField.text;
var text = inputField.textComponent;
var textTarget = targetInputField.textComponent;
text.alignment = textTarget.alignment;
text.color = textTarget.color;
text.fontSize = textTarget.fontSize;
}
}
}