Files
ichni_Creator_Studio/Assets/Scripts/DynamicUI/DynamicUIElements/Simple/DynamicUIElement.cs
TRAfoer 28e8d54a7b 尝试优化Inspector的排版
在输数字的地方输入框的输入限制可以改成十进制数,这样就不会因为输了字母然后报错了
2025-02-20 03:15:42 +08:00

59 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Ichni.Editor
{
public abstract class DynamicUIElement : MonoBehaviour
{
public TMP_Text title;
public IBaseElement connectedBaseElement;
/// <summary>
/// 参数名,通过反射获取饿修改对应变量的值
/// </summary>
public string parameterName;
/// <summary>
/// 是否始终更新如果子类可能用到此变量则在子类中写Update即可注意如果最后仅有Text用到此变量直接移动它到Text即可
/// </summary>
public bool isAlwaysUpdated;
public virtual void Initialize(IBaseElement baseElement, string title, string parameterName)
{
this.connectedBaseElement = baseElement;
this.parameterName = parameterName;
if (title != string.Empty)
{
this.title.text = title;
}
else
{
this.title.gameObject.SetActive(false);
}
}
public virtual void DeviverSet(int DeviveNum){
float o=2f/DeviveNum;//因为所有的单UI都是根据2栏来的
Button[] childb=GetComponentsInChildren<Button>();
TMP_Text[] childt=GetComponentsInChildren<TMP_Text>();
foreach (var i in childb){
RectTransform rectTransform = i.GetComponent<RectTransform>();
rectTransform.sizeDelta=new Vector2(rectTransform.sizeDelta.x*o,rectTransform.sizeDelta.y);
}
foreach (var i in childt){
RectTransform rectTransform = i.GetComponent<RectTransform>();
rectTransform.sizeDelta=new Vector2(rectTransform.sizeDelta.x*o,rectTransform.sizeDelta.y);
}
}
//public abstract void ApplyParameters();
}
}