40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class UniversalScreen : MonoBehaviour
|
|
{
|
|
[Header("其他字段")]
|
|
[SerializeField] private TMP_Text[] textFields;
|
|
[SerializeField] private Image[] imageFields;
|
|
|
|
public void SetText(string fieldName, string text)
|
|
{
|
|
var targetField = textFields.FirstOrDefault(t => t.name == fieldName);
|
|
if (targetField != null)
|
|
{
|
|
targetField.text = text;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"UniversalScreen: 未找到字段{fieldName}");
|
|
}
|
|
}
|
|
|
|
public void SetImage(string fieldName, Sprite image)
|
|
{
|
|
var targetField = imageFields.FirstOrDefault(t => t.name == fieldName);
|
|
if (targetField != null)
|
|
{
|
|
targetField.sprite = image;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"UniversalScreen: 未找到字段{fieldName}");
|
|
}
|
|
}
|
|
}
|
|
} |