Skip to content

Commit fa5cf5f

Browse files
committed
feat(ResourceManager): 添加资源加载耗时统计功能
- 在 ProviderOperation 中添加 Duration 字段和加载时间记录方法 - 在 HandleBase 中暴露 Duration 属性 - 所有 Provider 在 InternalOnStart 中开始记录加载时间
1 parent 2ff9fec commit fa5cf5f

13 files changed

Lines changed: 104 additions & 20 deletions

Runtime/ResourceManager/Handle/HandleBase.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ public float Progress
9090
}
9191
}
9292

93+
/// <summary>
94+
/// 加载耗时
95+
/// </summary>
96+
public long Duration
97+
{
98+
get
99+
{
100+
if (IsValidWithWarning == false)
101+
{
102+
return 0;
103+
}
104+
105+
return Provider.Duration;
106+
}
107+
}
108+
93109
/// <summary>
94110
/// 是否加载完毕
95111
/// </summary>
@@ -195,4 +211,4 @@ object IEnumerator.Current
195211

196212
#endregion
197213
}
198-
}
214+
}

Runtime/ResourceManager/Provider/BundledAllAssetsProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
44

@@ -18,6 +18,7 @@ public BundledAllAssetsProvider(ResourceManager manager, string providerGUID, As
1818
[UnityEngine.Scripting.Preserve]
1919
public override void InternalOnStart()
2020
{
21+
BeginLoadTimeRecord();
2122
DebugBeginRecording();
2223
}
2324

Runtime/ResourceManager/Provider/BundledAssetProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
44

@@ -18,6 +18,7 @@ public BundledAssetProvider(ResourceManager manager, string providerGUID, AssetI
1818
[UnityEngine.Scripting.Preserve]
1919
public override void InternalOnStart()
2020
{
21+
BeginLoadTimeRecord();
2122
DebugBeginRecording();
2223
}
2324

Runtime/ResourceManager/Provider/BundledRawFileProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace YooAsset
1+
namespace YooAsset
22
{
33
[UnityEngine.Scripting.Preserve]
44
internal class BundledRawFileProvider : ProviderOperation
@@ -11,6 +11,7 @@ public BundledRawFileProvider(ResourceManager manager, string providerGUID, Asse
1111
[UnityEngine.Scripting.Preserve]
1212
public override void InternalOnStart()
1313
{
14+
BeginLoadTimeRecord();
1415
DebugBeginRecording();
1516
}
1617

Runtime/ResourceManager/Provider/BundledSceneProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using System.IO;
44
using UnityEngine;
@@ -32,6 +32,7 @@ public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetI
3232
[UnityEngine.Scripting.Preserve]
3333
public override void InternalOnStart()
3434
{
35+
BeginLoadTimeRecord();
3536
DebugBeginRecording();
3637
}
3738

@@ -160,4 +161,4 @@ public void UnSuspendLoad()
160161
}
161162
}
162163
}
163-
}
164+
}

Runtime/ResourceManager/Provider/BundledSubAssetsProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
44

@@ -18,6 +18,7 @@ public BundledSubAssetsProvider(ResourceManager manager, string providerGUID, As
1818
[UnityEngine.Scripting.Preserve]
1919
public override void InternalOnStart()
2020
{
21+
BeginLoadTimeRecord();
2122
DebugBeginRecording();
2223
}
2324

@@ -150,4 +151,4 @@ public override void InternalOnUpdate()
150151
}
151152
}
152153
}
153-
}
154+
}

Runtime/ResourceManager/Provider/CompletedProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace YooAsset
1+
namespace YooAsset
22
{
33
[UnityEngine.Scripting.Preserve]
44
internal sealed class CompletedProvider : ProviderOperation
@@ -11,6 +11,7 @@ public CompletedProvider(ResourceManager manager, AssetInfo assetInfo) : base(ma
1111
[UnityEngine.Scripting.Preserve]
1212
public override void InternalOnStart()
1313
{
14+
BeginLoadTimeRecord();
1415
}
1516

1617
[UnityEngine.Scripting.Preserve]
@@ -27,4 +28,4 @@ public void SetCompleted(string error)
2728
}
2829
}
2930
}
30-
}
31+
}

Runtime/ResourceManager/Provider/DatabaseAllAssetsProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
44

@@ -15,6 +15,7 @@ public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, A
1515
[UnityEngine.Scripting.Preserve]
1616
public override void InternalOnStart()
1717
{
18+
BeginLoadTimeRecord();
1819
DebugBeginRecording();
1920
}
2021

@@ -126,4 +127,4 @@ public override void InternalOnUpdate()
126127
#endif
127128
}
128129
}
129-
}
130+
}

Runtime/ResourceManager/Provider/DatabaseAssetProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
44

@@ -15,6 +15,7 @@ public DatabaseAssetProvider(ResourceManager manager, string providerGUID, Asset
1515
[UnityEngine.Scripting.Preserve]
1616
public override void InternalOnStart()
1717
{
18+
BeginLoadTimeRecord();
1819
DebugBeginRecording();
1920
}
2021

@@ -106,4 +107,4 @@ public override void InternalOnUpdate()
106107
#endif
107108
}
108109
}
109-
}
110+
}

Runtime/ResourceManager/Provider/DatabaseRawFileProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace YooAsset
1+
namespace YooAsset
22
{
33
[UnityEngine.Scripting.Preserve]
44
internal class DatabaseRawFileProvider : ProviderOperation
@@ -11,6 +11,7 @@ public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, Ass
1111
[UnityEngine.Scripting.Preserve]
1212
public override void InternalOnStart()
1313
{
14+
BeginLoadTimeRecord();
1415
DebugBeginRecording();
1516
}
1617

@@ -70,4 +71,4 @@ public override void InternalOnUpdate()
7071
#endif
7172
}
7273
}
73-
}
74+
}

0 commit comments

Comments
 (0)