From 1fe4ffba72f56ccc6a89d1896142425c666887d4 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 14:15:08 +0800 Subject: =?UTF-8?q?+UILib=20=E5=8F=8D=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client/Assets/Scripts/UILib/XUIObjectBase.cs | 133 +++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Client/Assets/Scripts/UILib/XUIObjectBase.cs (limited to 'Client/Assets/Scripts/UILib/XUIObjectBase.cs') diff --git a/Client/Assets/Scripts/UILib/XUIObjectBase.cs b/Client/Assets/Scripts/UILib/XUIObjectBase.cs new file mode 100644 index 00000000..8744f6bb --- /dev/null +++ b/Client/Assets/Scripts/UILib/XUIObjectBase.cs @@ -0,0 +1,133 @@ +using System; +using UILib; +using UnityEngine; + +public abstract class XUIObjectBase : MonoBehaviour, IXUIObject +{ + public virtual IXUIObject parent + { + get + { + return this.m_parent; + } + set + { + this.m_parent = value; + } + } + + public ulong ID + { + get + { + return this.m_id; + } + set + { + this.m_id = value; + } + } + + public bool Exculsive + { + get + { + return this.m_bExculsive; + } + set + { + this.m_bExculsive = value; + } + } + + private IXUIObject m_parent = null; + + private ulong m_id; + + private bool m_bExculsive = false; + + public bool IsVisible() + { + return base.gameObject.activeInHierarchy; + } + + public virtual void SetVisible(bool bVisible) + { + base.gameObject.SetActive(bVisible); + } + + public virtual void OnFocus() + { + bool flag = this.parent != null; + if (flag) + { + this.parent.OnFocus(); + } + } + + public IXUIObject GetUIObject(string strName) + { + Transform transform = base.transform.Find(strName); + bool flag = null != transform; + IXUIObject result; + if (flag) + { + result = transform.GetComponent(); + } + else + { + result = null; + } + return result; + } + + public virtual void Highlight(bool bTrue) + { + } + + protected virtual void OnPress(bool isPressed) + { + this.OnFocus(); + } + + protected virtual void OnDrag(Vector2 delta) + { + this.OnFocus(); + } + + public virtual void Init() + { + } + + protected virtual void OnAwake() + { + } + + protected virtual void OnStart() + { + } + + protected virtual void OnUpdate() + { + } + + private void Awake() + { + this.OnAwake(); + } + + private void Start() + { + this.OnStart(); + } + + + + GameObject IXUIObject.gameObject + { + get + { + return base.gameObject; + } + } +} -- cgit v1.1-26-g67d0