Skip to content

Commit

Permalink
optimized CoreFrame update behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Aug 23, 2023
1 parent e7968d6 commit 277cff3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Assets/OxGFrame/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELOG

## [2.7.5] - 2023-08-23
- Optimized UIBase and SRBase of CoreFrame update behaviour call by FrameManager.
- Optimized CPBase of CoreFrame update behaviour, if need to update have to call by self to drive.
- Added DriveSelfUpdate(float dt) method in CPBase (drive by self).
```
public class NewTplCP : CPBase
{
private void Update()
{
this.DriveSelfUpdate(Time.deltaTime);
}
}
```

## [2.7.4] - 2023-08-15
- Fixed DeliveryQueryService is null bug issue.
- Modified InitAppPackage, InitDlcPackage, InitCustomPackage param of methods, add IDeliveryQueryServices interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace OxGFrame.CoreFrame.CPFrame
[HidePropertiesInInspector("onCloseAndDestroy", "allowInstantiate")]
public class CPBase : FrameBase
{
protected void DriveSelfUpdate(float dt) => this.DriveUpdate(dt);

private void OnEnable()
{
if (!this._isInitFirst) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ public TComponent[] GetNodeComponents<TComponent>(string bindName)
[Tooltip("If checked will destroy on close"), ConditionalField(nameof(allowInstantiate), true)]
public bool onCloseAndDestroy = false; // 是否關閉時就 DestroyUI

private void Update()
internal virtual void DriveUpdate(float dt)
{
if (!this._isInitFirst) return;

this.OnUpdate(Time.deltaTime);
this.OnUpdate(dt);
}

#if UNITY_EDITOR
private void OnValidate()
{
if (this.allowInstantiate) this.onCloseAndDestroy = false;
}
#endif

/// <summary>
/// 起始初始 (僅執行一次)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OxGFrame.AssetLoader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;

Expand Down Expand Up @@ -101,6 +102,30 @@ public U Pop()
this._loadingFlags = null;
}

private void Update()
{
if (this._dictAllCache.Count > 0)
{
float dt = Time.deltaTime;

var fStacks = this._dictAllCache.Values.ToArray();
foreach (var fStack in fStacks)
{
// 判斷陣列長度是否有改變, 有改變表示陣列元素有更動
if (this._dictAllCache.Count != fStacks.Length) break;

var fBases = fStack.cache.ToArray();
foreach (var fBase in fBases)
{
if (fStack.Count() != fBases.Length) break;

// 僅刷新顯示中的物件
if (this.CheckIsShowing(fBase)) fBase.DriveUpdate(dt);
}
}
}
}

/// <summary>
/// 判斷是否有在 LoadingFlags 中
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Assets/OxGFrame/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "com.michaelo.oxgframe",
"displayName": "OxGFrame",
"description": "The OxGFrame is a framework based on Unity for accelerating game development. Supports multi-platform Win, Android, iOS, WebGL.",
"version": "2.7.4",
"description": "The OxGFrame is a framework based on Unity for accelerating game development. Supports multi-platform Win, OSX, Android, iOS, WebGL.",
"version": "2.7.5",
"unity": "2021.3",
"license": "MIT",
"samples": [
Expand Down
2 changes: 1 addition & 1 deletion Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "5de16c9849c936e0476afcc4b300425008730caa"
"hash": "79ce65b0b1949910b4e2484ce82833891ae863f3"
},
"com.unity.2d.animation": {
"version": "7.0.10",
Expand Down

0 comments on commit 277cff3

Please sign in to comment.