diff --git a/source/src/devtools/data.ts b/source/src/devtools/data.ts index 93aee58..bf3aa34 100644 --- a/source/src/devtools/data.ts +++ b/source/src/devtools/data.ts @@ -142,6 +142,24 @@ export class Group { addProperty(property: Property) { this.data.push(property) } + + sort() { + let order = ['name', 'uuid', 'position', 'rotation', 'scale', 'anchor', 'size', 'color', 'opacity', 'skew', 'group']; + let orderKeys: Array = []; + let otherKeys: Array = []; + this.data.forEach(property => { + if (order.find(el => el === property.name)) { + orderKeys.push(property) + } else { + otherKeys.push(property); + } + }) + orderKeys.sort((a, b) => { + return order.indexOf(a.name) - order.indexOf(b.name); + }) + otherKeys.sort(); + this.data = orderKeys.concat(otherKeys); + } } export const testData = [ diff --git a/source/src/devtools/inject.ts b/source/src/devtools/inject.ts index 97e0cb0..0047100 100644 --- a/source/src/devtools/inject.ts +++ b/source/src/devtools/inject.ts @@ -176,6 +176,7 @@ class CCInspector { rotation: ["rotationX", "rotationY"], anchor: ["anchorX", "anchorY"], size: ["width", "height"], + skew: ['skewX', 'skewY'], position: ["x", "y", "z"], scale: ["scaleX", "scaleY", "scaleZ"], designResolution: ["width", "height"], // 这个比较特殊,在key下边,其他的都不是在key下 @@ -230,16 +231,18 @@ class CCInspector { _getGroupData(node: any) { let nodeGroup = new Group(node.constructor.name); let keys = this._getNodeKeys(node); - for (let i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length;) { let key = keys[i]; let propertyValue = node[key]; let pair = this._getPairProperty(key); if (pair) { + let bSplice = false; // 把这个成对的属性剔除掉 pair.values.forEach((item: string) => { let index = keys.findIndex(el => el === item); if (index !== -1) { keys.splice(index, 1); + bSplice = true; } }); // 序列化成对的属性 @@ -265,14 +268,19 @@ class CCInspector { let property = new Property(pair.key, info); nodeGroup.addProperty(property); } + if (!bSplice) { + i++; + } } else { let propertyPath = [node.uuid, key]; let info = this._genInfoData(propertyValue, propertyPath); if (info) { nodeGroup.addProperty(new Property(key, info)); } + i++; } } + nodeGroup.sort(); return nodeGroup; } @@ -310,6 +318,7 @@ class CCInspector { let nodeOrComp = this.inspectorGameMemoryStorage[uuid]; if (nodeOrComp && key in nodeOrComp) { debugger + function circleFind(base: Object): boolean { let obj = Object.getPrototypeOf(base); let ret = Object.getOwnPropertyDescriptor(obj, key)