123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Reflection;
- using TMPro;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- namespace TFramework
- {
- [Serializable]
- public class UIBehaviour : Behaviour
- {
- private RectTransform _rt;
- /// <summary>
- /// 启用动画
- /// </summary>
- [SerializeField]
- private bool enableAnim = false;
-
- public string m_uiAnimType;
- private UIAnimBase uIAnim;
- public RectTransform rectTransform => _rt = _rt ?? GetComponent<RectTransform>();
- public bool IsEnableAnim
- {
- get
- {
- if (enableAnim)
- {
- if (uIAnim == null)
- uIAnim = GlobalTool.CretaInstanceToCurrentDomain<UIAnimBase>(m_uiAnimType);
- }
- return enableAnim;
- }
- set
- {
- enableAnim = value;
- }
- }
- [SerializeField]
- private bool isScriptUse;
- [SerializeField]
- private List<VariableInfo> variableInfos;
- [SerializeField]
- private string parnetPanel;
- [SerializeField]
- private List<UseResInfo> useResInfos;
- public override void Start()
- {
- base.Start();
- }
- private void OnEnable()
- {
- if (IsEnableAnim)
- uIAnim.EnableAnim(rectTransform);
- }
- private void OnDisable()
- {
- if (IsEnableAnim)
- uIAnim.DisableAnim(rectTransform);
- }
- public UnityEngine.Object GetRes(string resName)
- {
- return useResInfos.Find(p => p.resName.Equals(resName))?.resObj;
- }
- #region Text
-
- /// <summary>
- /// 获取TextPro文本在本地化语言配置表的编号
- /// </summary>
- /// <returns></returns>
- public int GetLanguageId()
- {
- Text text = GetComponent<Text>();
- if (text)
- return (text as LocalizedLanguageText) == null ? -1 : (text as LocalizedLanguageText).lacalizedLanguageId;
- else
- return -1;
- }
- #endregion
- }
- [Serializable]
- public class VariableInfo
- {
- public string variableName;
- public string compentType;
- }
- [Serializable]
- public class UseResInfo
- {
- public UnityEngine.Object resObj;
- public string resName;
- }
- }
|