@cc-component/cc-core 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27,7 +27,6 @@ export abstract class BaseLoading extends Component {
|
|
|
27
27
|
progress_ratio: number = 1
|
|
28
28
|
/**总进度 值范围 0-100*/
|
|
29
29
|
pro_total: number;
|
|
30
|
-
is_init: boolean = false;
|
|
31
30
|
|
|
32
31
|
sceneParam: ISceneParam = {
|
|
33
32
|
param: null,
|
|
@@ -45,26 +44,24 @@ export abstract class BaseLoading extends Component {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
async Init() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
this.pro_total = (this.pro_total + temp_pro)
|
|
63
|
-
}
|
|
64
|
-
console.log("完成", this.pro_total)
|
|
65
|
-
// ✅ 先调用子类的 Finish(允许子类做自定义操作)
|
|
66
|
-
await this.Finish(); // 支持异步
|
|
47
|
+
const count = this.path_list.length;
|
|
48
|
+
const ratio = 1 / count * this.progress_ratio;
|
|
49
|
+
this.pro_total = 0;
|
|
50
|
+
MainModule.gui.progess.progess?.(0)//进度在OpenScene方法中先打开才可以 设置进度
|
|
51
|
+
for (let index = 0; index < this.path_list.length; index++) {
|
|
52
|
+
const key_path = this.path_list[index];
|
|
53
|
+
let temp_pro = 0;
|
|
54
|
+
await MainModule.loadDir(BundleConfig[key_path.bundleName], key_path.path, GetAssetType(key_path.type), (pro: number) => {
|
|
55
|
+
temp_pro = pro * ratio
|
|
56
|
+
const progess = (this.pro_total + pro * ratio)
|
|
57
|
+
MainModule.gui.progess.progess?.(progess)//进度在OpenScene方法中先打开才可以 设置进度
|
|
58
|
+
})
|
|
59
|
+
this.pro_total = (this.pro_total + temp_pro)
|
|
67
60
|
}
|
|
61
|
+
console.log("完成", this.pro_total)
|
|
62
|
+
// ✅ 先调用子类的 Finish(允许子类做自定义操作)
|
|
63
|
+
await this.Finish(); // 支持异步
|
|
64
|
+
|
|
68
65
|
this.FinishLoad()
|
|
69
66
|
}
|
|
70
67
|
|
|
@@ -93,11 +90,11 @@ export abstract class BaseLoading extends Component {
|
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
/** 模拟假加载进度(仅用于调试) */
|
|
96
|
-
loadProgress(durationSeconds: number = 2): Promise<void> {
|
|
93
|
+
loadProgress(durationSeconds: number = 2, max: number = 100): Promise<void> {
|
|
97
94
|
return new Promise((resolve) => {
|
|
98
95
|
let progress = 0;
|
|
99
96
|
const step = 1; // 每次增加 1%
|
|
100
|
-
const intervalMs = (durationSeconds * 1000) /
|
|
97
|
+
const intervalMs = (durationSeconds * 1000) / max; // 总毫秒数 / 100 步
|
|
101
98
|
const timer = setInterval(() => {
|
|
102
99
|
progress += step;
|
|
103
100
|
if (progress >= 100) {
|
|
@@ -52,13 +52,13 @@ export class ProgessWindow extends Component {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/***更新进度 */
|
|
55
|
-
public ProgessValue(value: number) {
|
|
55
|
+
public ProgessValue(value: number, anim_time: number = 0.1) {
|
|
56
56
|
if (this.pro_bar) {
|
|
57
57
|
this.onProgress?.(value)
|
|
58
58
|
if (this.pro_lb) {
|
|
59
59
|
this.pro_lb.string = `${value}%`
|
|
60
60
|
}
|
|
61
|
-
this.pro(this.pro_bar, value, 100,
|
|
61
|
+
this.pro(this.pro_bar, value, 100, anim_time);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|