Update AssetSystem

pull/4/head
hevinci 2022-04-22 16:43:09 +08:00
parent e6422445a6
commit cd62c1dd9a
2 changed files with 5 additions and 8 deletions

View File

@ -12,7 +12,6 @@ namespace YooAsset
private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000); private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000);
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000); private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100); private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
private static string _mainSceneName = string.Empty;
/// <summary> /// <summary>
/// 在编辑器下模拟运行 /// 在编辑器下模拟运行
@ -38,7 +37,6 @@ namespace YooAsset
AssetLoadingMaxNumber = assetLoadingMaxNumber; AssetLoadingMaxNumber = assetLoadingMaxNumber;
DecryptionServices = decryptionServices; DecryptionServices = decryptionServices;
BundleServices = bundleServices; BundleServices = bundleServices;
_mainSceneName = SceneManager.GetActiveScene().name;
} }
/// <summary> /// <summary>
@ -144,7 +142,6 @@ namespace YooAsset
if (sceneMode == LoadSceneMode.Single) if (sceneMode == LoadSceneMode.Single)
{ {
UnloadAllScene(); UnloadAllScene();
_mainSceneName = Path.GetFileName(scenePath);
} }
ProviderBase provider = TryGetProvider(scenePath); ProviderBase provider = TryGetProvider(scenePath);
@ -154,7 +151,7 @@ namespace YooAsset
provider = new DatabaseSceneProvider(scenePath, sceneMode, activateOnLoad, priority); provider = new DatabaseSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
else else
provider = new BundledSceneProvider(scenePath, sceneMode, activateOnLoad, priority); provider = new BundledSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
provider.SetSpawnDebugInfo(_mainSceneName); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
@ -175,7 +172,7 @@ namespace YooAsset
provider = new DatabaseAssetProvider(assetPath, assetType); provider = new DatabaseAssetProvider(assetPath, assetType);
else else
provider = new BundledAssetProvider(assetPath, assetType); provider = new BundledAssetProvider(assetPath, assetType);
provider.SetSpawnDebugInfo(_mainSceneName); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
return provider.CreateHandle() as AssetOperationHandle; return provider.CreateHandle() as AssetOperationHandle;
@ -193,7 +190,7 @@ namespace YooAsset
provider = new DatabaseSubAssetsProvider(assetPath, assetType); provider = new DatabaseSubAssetsProvider(assetPath, assetType);
else else
provider = new BundledSubAssetsProvider(assetPath, assetType); provider = new BundledSubAssetsProvider(assetPath, assetType);
provider.SetSpawnDebugInfo(_mainSceneName); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
return provider.CreateHandle() as SubAssetsOperationHandle; return provider.CreateHandle() as SubAssetsOperationHandle;

View File

@ -244,9 +244,9 @@ namespace YooAsset
public string SpawnTime = string.Empty; public string SpawnTime = string.Empty;
[Conditional("DEBUG")] [Conditional("DEBUG")]
public void SetSpawnDebugInfo(string spawnScene) public void InitSpawnDebugInfo()
{ {
SpawnScene = spawnScene; SpawnScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; ;
SpawnTime = SpawnTimeToString(UnityEngine.Time.realtimeSinceStartup); SpawnTime = SpawnTimeToString(UnityEngine.Time.realtimeSinceStartup);
} }
private string SpawnTimeToString(float spawnTime) private string SpawnTimeToString(float spawnTime)