Skip to content

Commit 7bd8026

Browse files
authored
Fix root path can not query normally & fix .meta file can not query normally. (#416)
1 parent 099c6b2 commit 7bd8026

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/api/scene/node-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export const SchemaNodeSearch = SchemaNodeIdentifier.extend({
4949

5050
// 查询节点的参数
5151
export const SchemaNodeQuery = z.object({
52-
path: z.string().describe('Node path'), // 节点路径
52+
path: z.string().describe('Node path, root path is "/"'), // 节点路径
5353
queryChildren: z.boolean().default(false).describe('Whether to query child node information'), // 是否查询子节点信息
54-
queryComponent: z.boolean().default(false).describe('Whether to query component`s information, the child component only returns concise information.'), // 是否查询组件信息,子节点只返回简易的信息
54+
queryComponent: z.boolean().default(false).describe('Whether to query component`s detailed information, the child component only returns concise information.'), // 是否查询组件信息,子节点只返回简易的信息
5555
}).describe('Query options for nodes, the result is the intersection of the passed information'); // 查询节点的选项参数,查询结果是传入的信息的交集
5656

5757
// 查询节点的结果

src/core/assets/manager/query.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isAbsolute, basename, extname } from 'path';
33
import { QueryAssetType, IAsset } from '../@types/protected';
44
import { AssetHandlerType, IAssetInfo, IAssetMeta, QueryAssetsOption } from '../@types/public';
55
import { FilterPluginOptions, IPluginScriptInfo } from '../../scripting/interface';
6-
import { url2uuid, libArr2Obj, getExtendsFromCCType } from '../utils';
6+
import { url2uuid, libArr2Obj, getExtendsFromCCType, url2path } from '../utils';
77
import assetDBManager from './asset-db';
88
import assetHandlerManager from './asset-handler';
99
import script from '../../scripting';
@@ -602,6 +602,11 @@ class AssetQueryManager {
602602
ver: '1.0.0',
603603
};
604604
}
605+
const path = url2path(uuidOrURLOrPath);
606+
const metaInfo = assetDBManager.assetDBMap['assets'].metaManager.path2meta[path];
607+
if (metaInfo) {
608+
return metaInfo.json;
609+
}
605610
uuid = url2uuid(uuidOrURLOrPath);
606611
}
607612
const asset = queryAsset(uuid);

src/core/scene/common/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface INodeIdentifier {
9696

9797
// 节点查询参数接口
9898
export interface IQueryNodeParams {
99-
path: string; // 查询的深度
99+
path: string; // 查询的节点路径
100100
queryChildren: boolean; // 是否查询子节点信息
101101
queryComponent: boolean; // 是否查询component的详细信息
102102
}

src/core/scene/scene-process/service/node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ export class NodeService extends BaseService<INodeEvents> implements INodeServic
372372
async queryNode(params: IQueryNodeParams): Promise<INode | null> {
373373
try {
374374
await Service.Editor.lock();
375-
const node = NodeMgr.getNodeByPath(params.path);
375+
let node = NodeMgr.getNodeByPath(params.path);
376+
if (!params.path || params.path === '/') {
377+
node = Service.Editor.getRootNode();
378+
}
376379
if (!node) {
377380
return null;
378381
}

0 commit comments

Comments
 (0)