Skip to content

Commit 28ee5bf

Browse files
committed
updated to v3.2.1
1 parent c117c03 commit 28ee5bf

19 files changed

Lines changed: 1100 additions & 266 deletions

File tree

Assets/OxGFrame/CHANGELOG.md

Lines changed: 235 additions & 9 deletions
Large diffs are not rendered by default.

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/CPFrame/CPBase.cs

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,11 @@ namespace OxGFrame.CoreFrame.CPFrame
77
[HidePropertiesInInspector("onCloseAndDestroy", "allowInstantiate")]
88
public class CPBase : FrameBase
99
{
10-
/// <summary>
11-
/// If checked, it can be directly placed in the scene and driven by MonoBehaviour
12-
/// </summary>
13-
[Tooltip("If checked, it can be directly placed in the scene and driven by MonoBehaviour")]
14-
public bool monoDrive = false;
15-
16-
/// <summary>
17-
/// Flag for controlling the call order of OnShow
18-
/// </summary>
19-
internal bool initFirstByMono = false;
20-
21-
/// <summary>
22-
/// Drive by self MonoBehaviour Update
23-
/// </summary>
24-
/// <param name="dt"></param>
25-
protected void DriveSelfUpdate(float dt) => this.HandleUpdate(dt);
26-
27-
/// <summary>
28-
/// Drive by other MonoBehaviour Update
29-
/// </summary>
30-
/// <param name="dt"></param>
31-
public void DriveUpdate(float dt) => this.HandleUpdate(dt);
32-
33-
/// <summary>
34-
/// Drive by self MonoBehaviour FixedUpdate
35-
/// </summary>
36-
/// <param name="dt"></param>
37-
protected void DriveSelfFixedUpdate(float dt) => this.HandleFixedUpdate(dt);
38-
39-
/// <summary>
40-
/// Drive by other MonoBehaviour Update
41-
/// </summary>
42-
/// <param name="dt"></param>
43-
public void DriveFixedUpdate(float dt) => this.HandleFixedUpdate(dt);
44-
45-
/// <summary>
46-
/// Drive by self MonoBehaviour LateUpdate
47-
/// </summary>
48-
/// <param name="dt"></param>
49-
protected void DriveSelfLateUpdate(float dt) => this.HandleLateUpdate(dt);
50-
51-
/// <summary>
52-
/// Drive by other MonoBehaviour LateUpdate
53-
/// </summary>
54-
/// <param name="dt"></param>
55-
public void DriveLateUpdate(float dt) => this.HandleLateUpdate(dt);
56-
5710
private void Awake()
5811
{
5912
if (this.monoDrive)
6013
{
61-
this.SetNames(this.name);
14+
this.SetNames($"{nameof(this.monoDrive)}_{this.name}");
6215
this.OnCreate();
6316
this.InitFirst();
6417
}
@@ -68,7 +21,7 @@ private void OnEnable()
6821
{
6922
if (!this._isInitFirst)
7023
return;
71-
if (this.initFirstByMono)
24+
if (this.isMonoDriveDetected)
7225
return;
7326
this.OnShow();
7427
}
@@ -85,6 +38,30 @@ private void OnDestroy()
8538
AssetLoaders.UnloadAsset(this.assetName).Forget();
8639
}
8740

41+
#if OXGFRAME_CPFRAME_MONODRIVE_UPDATE_ON
42+
private void Update()
43+
{
44+
if (this.monoDrive)
45+
this.HandleUpdate(Time.deltaTime);
46+
}
47+
#endif
48+
49+
#if OXGFRAME_CPFRAME_MONODRIVE_FIXEDUPDATE_ON
50+
private void FixedUpdate()
51+
{
52+
if (this.monoDrive)
53+
this.HandleFixedUpdate(Time.fixedDeltaTime);
54+
}
55+
#endif
56+
57+
#if OXGFRAME_CPFRAME_MONODRIVE_LATEUPDATE_ON
58+
private void LateUpdate()
59+
{
60+
if (this.monoDrive)
61+
this.HandleLateUpdate(Time.deltaTime);
62+
}
63+
#endif
64+
8865
public override void OnCreate() { }
8966

9067
internal sealed override void InitFirst()
@@ -156,6 +133,12 @@ protected override void OnPreClose() { }
156133
[System.Obsolete("This is not supported in this class.")]
157134
protected override void OnShow(object obj) { }
158135

136+
[System.Obsolete("This is not supported in this class.")]
137+
protected override void OnHide() { }
138+
139+
[System.Obsolete("This is not supported in this class.")]
140+
protected override void OnReveal() { }
141+
159142
[System.Obsolete("This is not supported in this class.")]
160143
public override void OnReceiveAndRefresh(object obj = null) { }
161144

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/CPFrame/CPManager.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ namespace OxGFrame.CoreFrame.CPFrame
77
{
88
internal class CPManager
99
{
10-
public float currentCount { get; protected set; } // [計算進度條用] 加載數量
11-
public float totalCount { get; protected set; } // [計算進度條用] 總加載數量
10+
/// <summary>
11+
/// [計算進度條用] 加載數量
12+
/// </summary>
13+
public float currentCount { get; protected set; }
14+
15+
/// <summary>
16+
/// [計算進度條用] 總加載數量
17+
/// </summary>
18+
public float totalCount { get; protected set; }
1219

1320
private static readonly object _locker = new object();
1421
private static CPManager _instance = null;
@@ -122,7 +129,7 @@ public void Preload<T>(string packageName, string[] assetNames, Progression prog
122129
bool active = instGo.activeSelf;
123130
if (!active)
124131
{
125-
cpBase.initFirstByMono = cpBase.monoDrive;
132+
cpBase.isMonoDriveDetected = cpBase.monoDrive;
126133
instGo.SetActive(true);
127134
}
128135

@@ -139,7 +146,7 @@ public void Preload<T>(string packageName, string[] assetNames, Progression prog
139146

140147
// 最後還原本身預製體的 Active
141148
instGo.SetActive(active);
142-
cpBase.initFirstByMono = false;
149+
cpBase.isMonoDriveDetected = false;
143150

144151
return cpBase;
145152
}
@@ -192,7 +199,7 @@ public void Preload<T>(string packageName, string[] assetNames, Progression prog
192199
bool active = instGo.activeSelf;
193200
if (!active)
194201
{
195-
cpBase.initFirstByMono = cpBase.monoDrive;
202+
cpBase.isMonoDriveDetected = cpBase.monoDrive;
196203
instGo.SetActive(true);
197204
}
198205

@@ -209,7 +216,7 @@ public void Preload<T>(string packageName, string[] assetNames, Progression prog
209216

210217
// 最後還原本身預製體的 Active
211218
instGo.SetActive(active);
212-
cpBase.initFirstByMono = false;
219+
cpBase.isMonoDriveDetected = false;
213220

214221
return cpBase;
215222
}

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/Implement/FrameBase.cs

Lines changed: 111 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public abstract class FrameBase : MonoBehaviour
1818
public class Collector : IDisposable
1919
{
2020
#region 依照綁定類型建立緩存容器
21-
// 用於存放綁定物件的緩存 (GameObject)
21+
/// <summary>
22+
/// 用於存放綁定物件的緩存 (GameObject)
23+
/// </summary>
2224
private Dictionary<string, List<GameObject>> _nodes = new Dictionary<string, List<GameObject>>();
2325
#endregion
2426

@@ -113,43 +115,131 @@ public void Dispose()
113115
}
114116
#endregion
115117

116-
[HideInInspector] public Collector collector { get; private set; } = new Collector(); // 綁定物件收集器
117-
[HideInInspector] public string assetName { get; protected set; } = string.Empty; // (Bundle) AssetName = (Resource) PathName
118-
[HideInInspector] public int groupId { get; protected set; } = 0; // 群組 id
119-
[HideInInspector] public bool isHidden { get; protected set; } = false; // 檢查是否隱藏 (主要區分 Close & Hide 行為)
118+
/// <summary>
119+
/// 綁定物件收集器
120+
/// </summary>
121+
[HideInInspector]
122+
public Collector collector { get; private set; } = new Collector();
123+
124+
/// <summary>
125+
/// (Bundle) AssetName = (Resource) PathName
126+
/// </summary>
127+
[HideInInspector]
128+
public string assetName { get; protected set; } = string.Empty;
129+
130+
/// <summary>
131+
/// 群組 id
132+
/// </summary>
133+
[HideInInspector]
134+
public int groupId { get; protected set; } = 0;
135+
136+
/// <summary>
137+
/// 檢查是否隱藏 (主要區分 Close & Hide 行為)
138+
/// </summary>
139+
[HideInInspector]
140+
public bool isHidden { get; protected set; } = false;
120141

121-
[HideInInspector] protected bool _isBinded { get; private set; } = false; // 檢查是否綁定的開關
122-
[HideInInspector] protected bool _isInitFirst { get; private set; } = false; // 是否初次初始
142+
/// <summary>
143+
/// 檢查是否綁定的開關
144+
/// </summary>
145+
[HideInInspector]
146+
protected bool _isBinded { get; private set; } = false;
147+
148+
/// <summary>
149+
/// 是否初次初始
150+
/// </summary>
151+
[HideInInspector]
152+
protected bool _isInitFirst { get; private set; } = false;
123153

154+
/// <summary>
155+
/// Flag for controlling the call order of OnShow (Used to indicate whether monoDrive is detected as enabled)
156+
/// </summary>
157+
internal bool isMonoDriveDetected = false;
158+
159+
/// <summary>
160+
/// If checked, it can be directly placed in the scene and driven by MonoBehaviour
161+
/// </summary>
162+
[Tooltip("If checked, it can be directly placed in the scene and driven by MonoBehaviour")]
163+
public bool monoDrive = false;
164+
165+
/// <summary>
166+
/// 是否允許多實例
167+
/// </summary>
124168
[Tooltip("Allow instantiate, but when close will destroy directly")]
125-
public bool allowInstantiate = false; // 是否允許多實例
169+
public bool allowInstantiate = false;
170+
171+
/// <summary>
172+
/// 是否關閉時就 DestroyUI
173+
/// </summary>
126174
[Tooltip("If checked, will destroy on close"), ConditionalField(nameof(allowInstantiate), true)]
127-
public bool onCloseAndDestroy = false; // 是否關閉時就 DestroyUI
175+
public bool onCloseAndDestroy = false;
176+
177+
#if UNITY_EDITOR
178+
private void OnValidate()
179+
{
180+
if (this.allowInstantiate)
181+
this.onCloseAndDestroy = false;
182+
}
183+
#endif
128184

129185
internal virtual void HandleUpdate(float dt)
130186
{
131-
if (!this._isInitFirst) return;
187+
if (!this._isInitFirst)
188+
return;
132189
this.OnUpdate(dt);
133190
}
134191

135192
internal virtual void HandleFixedUpdate(float dt)
136193
{
137-
if (!this._isInitFirst) return;
194+
if (!this._isInitFirst)
195+
return;
138196
this.OnFixedUpdate(dt);
139197
}
140198

141199
internal virtual void HandleLateUpdate(float dt)
142200
{
143-
if (!this._isInitFirst) return;
201+
if (!this._isInitFirst)
202+
return;
144203
this.OnLateUpdate(dt);
145204
}
146205

147-
#if UNITY_EDITOR
148-
private void OnValidate()
149-
{
150-
if (this.allowInstantiate) this.onCloseAndDestroy = false;
151-
}
152-
#endif
206+
#region For MonoDrive
207+
/// <summary>
208+
/// Drive by self MonoBehaviour Update
209+
/// </summary>
210+
/// <param name="dt"></param>
211+
protected void DriveSelfUpdate(float dt) => this.HandleUpdate(dt);
212+
213+
/// <summary>
214+
/// Drive by other MonoBehaviour Update
215+
/// </summary>
216+
/// <param name="dt"></param>
217+
public void DriveUpdate(float dt) => this.HandleUpdate(dt);
218+
219+
/// <summary>
220+
/// Drive by self MonoBehaviour FixedUpdate
221+
/// </summary>
222+
/// <param name="dt"></param>
223+
protected void DriveSelfFixedUpdate(float dt) => this.HandleFixedUpdate(dt);
224+
225+
/// <summary>
226+
/// Drive by other MonoBehaviour Update
227+
/// </summary>
228+
/// <param name="dt"></param>
229+
public void DriveFixedUpdate(float dt) => this.HandleFixedUpdate(dt);
230+
231+
/// <summary>
232+
/// Drive by self MonoBehaviour LateUpdate
233+
/// </summary>
234+
/// <param name="dt"></param>
235+
protected void DriveSelfLateUpdate(float dt) => this.HandleLateUpdate(dt);
236+
237+
/// <summary>
238+
/// Drive by other MonoBehaviour LateUpdate
239+
/// </summary>
240+
/// <param name="dt"></param>
241+
public void DriveLateUpdate(float dt) => this.HandleLateUpdate(dt);
242+
#endregion
153243

154244
/// <summary>
155245
/// 起始初始 (僅執行一次)
@@ -278,6 +368,9 @@ internal virtual void Dispose()
278368
this.collector = null;
279369
}
280370

371+
/// <summary>
372+
/// 調用關閉自己
373+
/// </summary>
281374
protected abstract void CloseSelf();
282375

283376
/// <summary>

Assets/OxGFrame/CoreFrame/Scripts/Runtime/Core/Implement/FrameManager.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace OxGFrame.CoreFrame
1111
{
12+
/// <summary>
13+
/// 信息刷新結構體
14+
/// </summary>
1215
public struct RefreshInfo
1316
{
1417
public string assetName;
@@ -31,8 +34,16 @@ internal enum UpdateType
3134
LateUpdate
3235
}
3336

37+
/// <summary>
38+
/// 緩存回調
39+
/// </summary>
40+
/// <param name="fBase"></param>
3441
protected delegate void AddIntoCache(T fBase);
3542

43+
/// <summary>
44+
/// 核心緩存機制
45+
/// </summary>
46+
/// <typeparam name="U"></typeparam>
3647
protected class FrameStack<U> where U : T
3748
{
3849
public bool isPreloadMode { get; private set; }
@@ -120,17 +131,25 @@ public U Pop()
120131
public bool enabledFixedUpdate = false;
121132
public bool enabledLateUpdate = false;
122133

123-
public float currentCount { get; protected set; } // [計算進度條用] 加載數量
124-
public float totalCount { get; protected set; } // [計算進度條用] 總加載數量
134+
/// <summary>
135+
/// [計算進度條用] 加載數量
136+
/// </summary>
137+
public float currentCount { get; protected set; }
125138

126-
protected Dictionary<string, FrameStack<T>> _dictAllCache = new Dictionary<string, FrameStack<T>>(); // 【常駐】所有緩存 (只會在 Destroy 時, Remove 對應的緩存)
127-
protected HashSet<string> _loadingFlags = new HashSet<string>(); // 用來標記正在加載中的資源 (暫存緩存)
139+
/// <summary>
140+
/// [計算進度條用] 總加載數量
141+
/// </summary>
142+
public float totalCount { get; protected set; }
128143

129-
~FrameManager()
130-
{
131-
this._dictAllCache = null;
132-
this._loadingFlags = null;
133-
}
144+
/// <summary>
145+
/// 【常駐】所有緩存 (只會在 Destroy 時, Remove 對應的緩存)
146+
/// </summary>
147+
protected Dictionary<string, FrameStack<T>> _dictAllCache = new Dictionary<string, FrameStack<T>>();
148+
149+
/// <summary>
150+
/// 用來標記正在加載中的資源 (暫存緩存)
151+
/// </summary>
152+
protected HashSet<string> _loadingFlags = new HashSet<string>();
134153

135154
private static float _dt;
136155
private static float _fdt;

0 commit comments

Comments
 (0)