-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathUGFUIWidget.cs
73 lines (66 loc) · 1.98 KB
/
UGFUIWidget.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using MongoDB.Bson.Serialization.Attributes;
using UnityEngine;
namespace ET
{
[ChildOf(typeof(UGFUIForm))]
public sealed class UGFUIWidget : Entity, IAwake<Transform, long>, IDestroy
{
[BsonIgnore]
public Transform Transform { get; private set; }
public long WidgetEventTypeLongHashCode { get; private set; }
public bool IsOpen { get; internal set; }
private bool m_Visible = false;
/// <summary>
/// 获取或设置界面是否可见。
/// </summary>
public bool Visible
{
get
{
return IsOpen && m_Visible;
}
internal set
{
if (!IsOpen)
{
Log.Warning($"UI widget '{Transform.name}' is not available.");
return;
}
if (m_Visible == value)
{
return;
}
m_Visible = value;
Transform.gameObject.SetActive(value);
}
}
internal void OnAwake(Transform transform, long widgetEventTypeLongHashCode)
{
Transform = transform;
WidgetEventTypeLongHashCode = widgetEventTypeLongHashCode;
}
internal void OnDestroy()
{
Transform = default;
WidgetEventTypeLongHashCode = default;
IsOpen = false;
m_Visible = false;
}
}
[EntitySystemOf(typeof(UGFUIWidget))]
[FriendOf(typeof(UGFUIWidget))]
public static partial class UGFUIWidgetSystem
{
[EntitySystem]
private static void Awake(this UGFUIWidget self, Transform transform, long widgetEventTypeLongHashCode)
{
self.OnAwake(transform, widgetEventTypeLongHashCode);
}
[EntitySystem]
private static void Destroy(this UGFUIWidget self)
{
self.OnDestroy();
}
}
}