Ship the WeChat hot-update catalogs and the camp, TideWhale T2, UI atlas, and animation-lab work.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace HotUpdate.UI
|
||||
{
|
||||
/// <summary>编辑器生成与运行时加载共用的目录约定。</summary>
|
||||
public static class UiAtlasPaths
|
||||
{
|
||||
public const string TextureRoot = "Assets/Bundles/UI/Texture";
|
||||
public const string AtlasRoot = "Assets/Bundles/UI/Atlas";
|
||||
public const string AtlasNamePrefix = "UI_";
|
||||
|
||||
public static bool IsTexturePath(string path)
|
||||
{
|
||||
return path != null && path.Replace('\\', '/').StartsWith(TextureRoot + "/", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string GetAtlasName(string relativeFolder)
|
||||
{
|
||||
if (relativeFolder == null) throw new ArgumentNullException(nameof(relativeFolder));
|
||||
relativeFolder = relativeFolder.Replace('\\', '/').Trim('/');
|
||||
if (relativeFolder.Length == 0) return AtlasNamePrefix + "__RootAtlas";
|
||||
foreach (string segment in relativeFolder.Split('/'))
|
||||
if (segment.Length == 0 || segment == "." || segment == "..")
|
||||
throw new ArgumentException("Invalid UI texture folder: " + relativeFolder);
|
||||
// 转义下划线与路径分隔符,避免 A/B 与 A_B 生成同名图集。
|
||||
return AtlasNamePrefix + relativeFolder.Replace("_", "_u").Replace("/", "_s") + "Atlas";
|
||||
}
|
||||
|
||||
public static string GetAtlasPath(string relativeFolder)
|
||||
{
|
||||
return AtlasRoot + "/" + GetAtlasName(relativeFolder) + ".spriteatlas";
|
||||
}
|
||||
|
||||
public static string GetAtlasPathForTexture(string texturePath)
|
||||
{
|
||||
texturePath = texturePath?.Replace('\\', '/');
|
||||
if (!IsTexturePath(texturePath)) throw new ArgumentException("Not a UI texture: " + texturePath);
|
||||
int lastSlash = texturePath.LastIndexOf('/');
|
||||
string folder = lastSlash == TextureRoot.Length ? "" :
|
||||
texturePath.Substring(TextureRoot.Length + 1, lastSlash - TextureRoot.Length - 1);
|
||||
return GetAtlasPath(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user