Example #1
0
 /// <summary>
 /// 获取基于流文件夹的加载路径
 /// </summary>
 public static string MakeStreamingLoadPath(string path)
 {
     return(StringUtility.Format("{0}/YooAssets/{1}", UnityEngine.Application.streamingAssetsPath, path));
 }
Example #2
0
        /// <summary>
        /// 获取基于沙盒文件夹的加载路径
        /// </summary>
        public static string MakePersistentLoadPath(string path)
        {
            string root = MakePersistentRootPath();

            return(StringUtility.Format("{0}/{1}", root, path));
        }
Example #3
0
        /// <summary>
        /// 初始化资源路径映射
        /// </summary>
        public void InitAssetPathMapping(bool locationToLower)
        {
            if (_isInitAssetPathMapping)
            {
                return;
            }
            _isInitAssetPathMapping = true;

            if (EnableAddressable)
            {
                if (locationToLower)
                {
                    YooLogger.Error("Addressable not support location to lower !");
                }

                foreach (var patchAsset in AssetList)
                {
                    string location = patchAsset.Address;
                    if (AssetPathMapping.ContainsKey(location))
                    {
                        throw new Exception($"Address have existed : {location}");
                    }
                    else
                    {
                        AssetPathMapping.Add(location, patchAsset.AssetPath);
                    }
                }
            }
            else
            {
                _locationToLower = locationToLower;
                foreach (var patchAsset in AssetList)
                {
                    string location = patchAsset.AssetPath;
                    if (locationToLower)
                    {
                        location = location.ToLower();
                    }

                    // 添加原生路径的映射
                    if (AssetPathMapping.ContainsKey(location))
                    {
                        throw new Exception($"AssetPath have existed : {location}");
                    }
                    else
                    {
                        AssetPathMapping.Add(location, patchAsset.AssetPath);
                    }

                    // 添加无后缀名路径的映射
                    if (Path.HasExtension(location))
                    {
                        string locationWithoutExtension = StringUtility.RemoveExtension(location);
                        if (AssetPathMapping.ContainsKey(locationWithoutExtension))
                        {
                            YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
                        }
                        else
                        {
                            AssetPathMapping.Add(locationWithoutExtension, patchAsset.AssetPath);
                        }
                    }
                }
            }
        }