Update runtime code

pull/51/head
hevinci 2022-10-22 17:46:46 +08:00
parent 8eb7816e30
commit ec1c3d6070
7 changed files with 46 additions and 4 deletions

View File

@ -344,6 +344,7 @@ namespace YooAsset
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
providerInfo.SpawnScene = provider.SpawnScene;
providerInfo.SpawnTime = provider.SpawnTime;
providerInfo.LoadingTime = provider.LoadingTime;
providerInfo.RefCount = provider.RefCount;
providerInfo.Status = (int)provider.Status;
providerInfo.DependBundleInfos = new List<DebugBundleInfo>();

View File

@ -22,6 +22,8 @@ namespace YooAsset
}
public override void Update()
{
DebugRecording();
if (IsDone)
return;

View File

@ -3,12 +3,12 @@ using System.Collections.Generic;
namespace YooAsset
{
internal abstract class BundledProvider : ProviderBase
{
internal abstract class BundledProvider : ProviderBase
{
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
protected DependAssetBundleGroup DependBundleGroup { private set; get; }
public BundledProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
public BundledProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
{
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
OwnerBundle.Reference();

View File

@ -32,6 +32,8 @@ namespace YooAsset
}
public override void Update()
{
DebugRecording();
if (IsDone)
return;
@ -97,7 +99,7 @@ namespace YooAsset
SceneManager.SetActiveScene(SceneObject);
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
if(Status == EStatus.Fail)
if (Status == EStatus.Fail)
{
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError);

View File

@ -22,6 +22,8 @@ namespace YooAsset
}
public override void Update()
{
DebugRecording();
if (IsDone)
return;

View File

@ -238,6 +238,17 @@ namespace YooAsset
/// </summary>
public string SpawnTime = string.Empty;
/// <summary>
/// 加载耗时(单位:毫秒)
/// </summary>
public long LoadingTime { protected set; get; }
#if DEBUG
// 加载耗时统计
private bool _isRecording = false;
private Stopwatch _watch;
#endif
[Conditional("DEBUG")]
public void InitSpawnDebugInfo()
{
@ -251,6 +262,25 @@ namespace YooAsset
float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
}
[Conditional("DEBUG")]
protected void DebugRecording()
{
if (_isRecording == false)
{
_isRecording = true;
_watch = Stopwatch.StartNew();
}
if (_watch != null)
{
if (IsDone)
{
LoadingTime = _watch.ElapsedMilliseconds;
_watch = null;
}
}
}
#endregion
}
}

View File

@ -27,6 +27,11 @@ namespace YooAsset
/// </summary>
public string SpawnTime;
/// <summary>
/// 加载耗时(单位:毫秒)
/// </summary>
public long LoadingTime;
/// <summary>
/// 引用计数
/// </summary>