Support fast build mode.
支持快速构建模式,真实的实现EditorPlayMode的运行时环境。
This commit is contained in:
@@ -79,7 +79,7 @@ namespace YooAsset
|
||||
// 1. 准备工作
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromEditor)
|
||||
{
|
||||
_steps = ESteps.CheckAndCopyFile;
|
||||
return; // 模拟实现异步操作
|
||||
@@ -130,7 +130,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundleInfo == null)
|
||||
return string.Empty;
|
||||
return _bundleInfo.BundleName;
|
||||
return _bundleInfo.EditorAssetPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace YooAsset
|
||||
LoadFromStreaming,
|
||||
LoadFromCache,
|
||||
LoadFromRemote,
|
||||
LoadFromEditor,
|
||||
}
|
||||
|
||||
private readonly PatchBundle _patchBundle;
|
||||
@@ -32,6 +33,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
internal string RemoteFallbackURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器资源路径
|
||||
/// </summary>
|
||||
public string EditorAssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
@@ -113,6 +119,16 @@ namespace YooAsset
|
||||
BundleName = patchBundle.BundleName;
|
||||
RemoteMainURL = mainURL;
|
||||
RemoteFallbackURL = fallbackURL;
|
||||
EditorAssetPath = string.Empty;
|
||||
}
|
||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
||||
{
|
||||
_patchBundle = patchBundle;
|
||||
LoadMode = loadMode;
|
||||
BundleName = patchBundle.BundleName;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = editorAssetPath;
|
||||
}
|
||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||
{
|
||||
@@ -121,6 +137,7 @@ namespace YooAsset
|
||||
BundleName = patchBundle.BundleName;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = string.Empty;
|
||||
}
|
||||
internal BundleInfo(string bundleName)
|
||||
{
|
||||
@@ -129,6 +146,7 @@ namespace YooAsset
|
||||
BundleName = bundleName;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
@@ -16,12 +17,50 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
Builder,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorPlayModeImpl _impl;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorPlayModeInitializationOperation(EditorPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.Builder;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.Builder)
|
||||
{
|
||||
string manifestFilePath = EditorPlayModeHelper.DryRunBuild();
|
||||
if (string.IsNullOrEmpty(manifestFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Dry run build failed, see the detail info on the console window.";
|
||||
return;
|
||||
}
|
||||
if (File.Exists(manifestFilePath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Manifest file not found : {manifestFilePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
YooLogger.Log($"Load manifest file in editor play mode : {manifestFilePath}");
|
||||
string jsonContent = FileUtility.ReadFile(manifestFilePath);
|
||||
_impl.AppPatchManifest = PatchManifest.Deserialize(jsonContent);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +191,7 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 内置补丁清单加载器
|
||||
/// </summary>
|
||||
|
||||
@@ -51,10 +51,10 @@ namespace YooAsset
|
||||
public readonly Dictionary<string, PatchAsset> Assets = new Dictionary<string, PatchAsset>();
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址映射集合
|
||||
/// 资源路径映射集合
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public readonly Dictionary<string, string> AddressDic = new Dictionary<string, string>();
|
||||
public readonly Dictionary<string, string> AssetPathMapping = new Dictionary<string, string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -120,17 +120,39 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址转换为资源路径
|
||||
/// 尝试获取资源包的主资源路径
|
||||
/// </summary>
|
||||
public string ConvertAddress(string address)
|
||||
public string TryGetBundleMainAssetPath(string bundleName)
|
||||
{
|
||||
if (AddressDic.TryGetValue(address, out string assetPath))
|
||||
foreach (var patchAsset in AssetList)
|
||||
{
|
||||
int bundleID = patchAsset.BundleID;
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
if (patchBundle.BundleName == bundleName)
|
||||
return patchAsset.AssetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid depend id : {bundleID} Asset path : {patchAsset.AssetPath}");
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 映射为资源路径
|
||||
/// </summary>
|
||||
public string MappingToAssetPath(string location)
|
||||
{
|
||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
||||
{
|
||||
return assetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found address in patch manifest : {address}");
|
||||
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -162,36 +184,47 @@ namespace YooAsset
|
||||
// AssetList
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
string assetPath = patchAsset.AssetPath;
|
||||
|
||||
// 添加原始路径
|
||||
// 注意:我们不允许原始路径存在重名
|
||||
string assetPath = patchAsset.AssetPath;
|
||||
if (patchManifest.Assets.ContainsKey(assetPath))
|
||||
throw new Exception($"Asset path have existed : {assetPath}");
|
||||
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
patchManifest.Assets.Add(assetPath, patchAsset);
|
||||
|
||||
// 添加去掉后缀名的路径
|
||||
if (Path.HasExtension(assetPath))
|
||||
{
|
||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
||||
if (patchManifest.Assets.ContainsKey(assetPathWithoutExtension))
|
||||
YooLogger.Warning($"Asset path have existed : {assetPathWithoutExtension}");
|
||||
else
|
||||
patchManifest.Assets.Add(assetPathWithoutExtension, patchAsset);
|
||||
}
|
||||
}
|
||||
|
||||
// Address
|
||||
// AssetPathMapping
|
||||
if (patchManifest.EnableAddressable)
|
||||
{
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
string address = patchAsset.Address;
|
||||
if (patchManifest.AddressDic.ContainsKey(address))
|
||||
if (patchManifest.AssetPathMapping.ContainsKey(address))
|
||||
throw new Exception($"Address have existed : {address}");
|
||||
else
|
||||
patchManifest.AddressDic.Add(address, patchAsset.AssetPath);
|
||||
patchManifest.AssetPathMapping.Add(address, patchAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
string assetPath = patchAsset.AssetPath;
|
||||
|
||||
// 添加原生路径的映射
|
||||
if (patchManifest.AssetPathMapping.ContainsKey(assetPath))
|
||||
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
patchManifest.AssetPathMapping.Add(assetPath, assetPath);
|
||||
|
||||
// 添加无后缀名路径的映射
|
||||
if (Path.HasExtension(assetPath))
|
||||
{
|
||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
||||
if (patchManifest.AssetPathMapping.ContainsKey(assetPathWithoutExtension))
|
||||
YooLogger.Warning($"AssetPath have existed : {assetPathWithoutExtension}");
|
||||
else
|
||||
patchManifest.AssetPathMapping.Add(assetPathWithoutExtension, assetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -3,18 +3,19 @@ using System.Reflection;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal static class LocationServicesHelper
|
||||
internal static class EditorPlayModeHelper
|
||||
{
|
||||
private static System.Type _classType;
|
||||
|
||||
public static void InitEditorPlayMode(bool enableAddressable)
|
||||
public static string DryRunBuild()
|
||||
{
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleGrouperRuntimeSupport");
|
||||
InvokePublicStaticMethod(_classType, "InitEditorPlayMode", enableAddressable);
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
||||
InvokePublicStaticMethod(_classType, "FastBuild");
|
||||
return GetPatchManifestFilePath();
|
||||
}
|
||||
public static string ConvertLocationToAssetPath(string location)
|
||||
private static string GetPatchManifestFilePath()
|
||||
{
|
||||
return (string)InvokePublicStaticMethod(_classType, "ConvertLocationToAssetPath", location);
|
||||
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestFilePath");
|
||||
}
|
||||
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
||||
{
|
||||
@@ -28,4 +29,9 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
internal static class EditorPlayModeHelper
|
||||
{
|
||||
public static string DryRunBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b39dcdab07554ca4ab4ace5ca97aee78
|
||||
guid: 5b09fe4b7aa2d2143bc538976541b039
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -6,12 +6,14 @@ namespace YooAsset
|
||||
{
|
||||
internal class EditorPlayModeImpl : IBundleServices
|
||||
{
|
||||
internal PatchManifest AppPatchManifest;
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync()
|
||||
{
|
||||
var operation = new EditorPlayModeInitializationOperation();
|
||||
var operation = new EditorPlayModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -21,27 +23,41 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int GetResourceVersion()
|
||||
{
|
||||
return 0;
|
||||
if (AppPatchManifest == null)
|
||||
return 0;
|
||||
return AppPatchManifest.ResourceVersion;
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
{
|
||||
YooLogger.Warning($"Editor play mode can not get bundle info.");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return new BundleInfo(string.Empty);
|
||||
|
||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||
{
|
||||
string mainAssetPath = AppPatchManifest.TryGetBundleMainAssetPath(bundleName);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
throw new Exception($"Editor play mode not support addressable.");
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return assetPath;
|
||||
return AppPatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return new string[] { };
|
||||
return AppPatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -309,9 +309,9 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return LocalPatchManifest.ConvertAddress(address);
|
||||
return LocalPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return AppPatchManifest.ConvertAddress(address);
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace YooAsset
|
||||
BundleInfo GetBundleInfo(string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址转换为资源路径
|
||||
/// 映射为资源路径
|
||||
/// </summary>
|
||||
string ConvertAddress(string address);
|
||||
string MappingToAssetPath(string location);
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源所属的资源包名称
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 定位地址转换为资源路径
|
||||
/// </summary>
|
||||
string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location);
|
||||
string ConvertLocationToAssetPath(string location);
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,9 @@ namespace YooAsset
|
||||
{
|
||||
public class AddressLocationServices : ILocationServices
|
||||
{
|
||||
public AddressLocationServices()
|
||||
public string ConvertLocationToAssetPath(string location)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
LocationServicesHelper.InitEditorPlayMode(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
||||
{
|
||||
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return LocationServicesHelper.ConvertLocationToAssetPath(location);
|
||||
#else
|
||||
throw new System.NotImplementedException();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return YooAssets.ConvertAddress(location);
|
||||
}
|
||||
return YooAssets.MappingToAssetPath(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,34 +9,19 @@ namespace YooAsset
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceRoot) == false)
|
||||
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
LocationServicesHelper.InitEditorPlayMode(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
||||
public string ConvertLocationToAssetPath(string location)
|
||||
{
|
||||
location = CombineAssetPath(_resourceRoot, location);
|
||||
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
||||
if (string.IsNullOrEmpty(_resourceRoot))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return LocationServicesHelper.ConvertLocationToAssetPath(location);
|
||||
#else
|
||||
throw new System.NotImplementedException();
|
||||
#endif
|
||||
return YooAssets.MappingToAssetPath(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
return location;
|
||||
string tempLocation = $"{_resourceRoot}/{location}";
|
||||
return YooAssets.MappingToAssetPath(tempLocation);
|
||||
}
|
||||
}
|
||||
private string CombineAssetPath(string root, string location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(root))
|
||||
return location;
|
||||
else
|
||||
return $"{root}/{location}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +310,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public static BundleInfo GetBundleInfo(string location)
|
||||
{
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||
return _bundleServices.GetBundleInfo(bundleName);
|
||||
}
|
||||
@@ -353,7 +353,7 @@ namespace YooAsset
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
string scenePath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string scenePath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||
return handle;
|
||||
}
|
||||
@@ -367,10 +367,11 @@ namespace YooAsset
|
||||
/// <param name="copyPath">拷贝路径</param>
|
||||
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
||||
{
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(assetPath);
|
||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
return operation;
|
||||
@@ -482,7 +483,7 @@ namespace YooAsset
|
||||
|
||||
private static AssetOperationHandle LoadAssetInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
||||
{
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
@@ -490,7 +491,7 @@ namespace YooAsset
|
||||
}
|
||||
private static SubAssetsOperationHandle LoadSubAssetsInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
||||
{
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
@@ -583,7 +584,7 @@ namespace YooAsset
|
||||
List<string> assetPaths = new List<string>(locations.Length);
|
||||
foreach (var location in locations)
|
||||
{
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
assetPaths.Add(assetPath);
|
||||
}
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetPaths, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -731,10 +732,37 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal static string ConvertAddress(string address)
|
||||
internal static string MappingToAssetPath(string location)
|
||||
{
|
||||
return _bundleServices.ConvertAddress(address);
|
||||
#if UNITY_EDITOR
|
||||
CheckLocation(location);
|
||||
#endif
|
||||
|
||||
return _bundleServices.MappingToAssetPath(location);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static void CheckLocation(string location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(location))
|
||||
{
|
||||
UnityEngine.Debug.LogError("location param is null or empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 检查路径末尾是否有空格
|
||||
int index = location.LastIndexOf(" ");
|
||||
if (index != -1)
|
||||
{
|
||||
if (location.Length == index + 1)
|
||||
UnityEngine.Debug.LogWarning($"Found blank character in location : \"{location}\"");
|
||||
}
|
||||
|
||||
if (location.IndexOfAny(System.IO.Path.GetInvalidPathChars()) >= 0)
|
||||
UnityEngine.Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user