Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine Supports Sub-Asset References and URL Mapping #119

Open
johanzhu opened this issue Dec 24, 2024 · 0 comments
Open

Engine Supports Sub-Asset References and URL Mapping #119

johanzhu opened this issue Dec 24, 2024 · 0 comments

Comments

@johanzhu
Copy link
Collaborator

背景

目前 spine loader 已经剔除了对编辑器资产的特殊处理逻辑。1.4开始,编辑器也不会修改 spine 原始文件。所以,引擎侧需要进行改造以支持正常加载 spine 动画文件。
同时,对于类似的多文件,且存在引用关系,且无法修改主文件的情况,引擎和编辑器也需要有一套方案。

方案设计

目前的 project.json结构
{
"md5": "68700ac0cf72f4ba92ee4a49739ef0a5",
"id": "3e3f00e6-c19b-4376-ac34-3cbfbfc791cd",
"virtualPath": "/yuyouyou.png",
"type": "EditorTexture2D",
"path": "https://mdn.alipayobjects.com/oasis_be/afts/file/A*dOS4T72_DQcAAAAAAAAAAAAADkp5AQ/yuyouyou.bin"
}

目前的逻辑都是单 url 纬度的。首先通过 initVirtualResources 方法,在引擎内创建 virtualPath 到 path 的映射。

在 loader 加载时,通过传入的路径在映射中寻找文件路径,找得到的话就是用这个路径,否则使用传入的路径。

新的设计:

增加一个 depndentAssets 字段,存储对子资源的引用。即:
{
"md5": "68700ac0cf72f4ba92ee4a49739ef0a5",
"id": "3e3f00e6-c19b-4376-ac34-3cbfbfc791cd",
"depndentAssets": {k:"/spine.json"},
"subVirtualPaths": "./spine.atlas"
"type": "EditorTexture2D",
"path": ["https://mdn.alipayobjects.com/oasis_be/afts/file/A*dOS4T72_DQcAAAAAAAAAAAAADkp5AQ/yuyouyou.json", "./spine.atlas"]
}

新的加载逻辑:

  1. 增加一个 _dependencyMap 存储主虚拟路径与 depndentAssets 的映射。

  2. loadSingleItem 逻辑调整:

加载单 url 时,如果识别到存在 depndentAssets,那么链式获取到全部的 path,传递到 loader 当中~

加载多 urls 时,loader 内部进行处理不同素材间的组合方式。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant