diff --git a/cc-inspector/src/scripts/inject/inspector.ts b/cc-inspector/src/scripts/inject/inspector.ts index 0e1beb1..ee307b1 100644 --- a/cc-inspector/src/scripts/inject/inspector.ts +++ b/cc-inspector/src/scripts/inject/inspector.ts @@ -472,6 +472,30 @@ export class Inspector extends InjectEvent { } } } + private getStep(node: any, key: string) { + const cfgArray: Array<{ type: any; keys: Array<{ key: string; step: number }> }> = []; + if (cc.Node) { + cfgArray.push({ + type: cc.Node, + keys: [ + { key: "anchorX", step: 0.1 }, + { key: "anchorY", step: 0.1 }, + { key: "scaleX", step: 0.1 }, + { key: "scaleY", step: 0.1 }, + ], + }); + } + for (let i = 0; i < cfgArray.length; i++) { + const { type, keys } = cfgArray[i]; + if (node instanceof type) { + const ret = keys.find((item) => item.key === key); + if (ret) { + return ret.step; + } + } + } + return 1; + } _genInfoData(node: any, key: string | number, path: Array): Info | null { this.warnSilent(true); const propertyValue = node[key]; @@ -494,6 +518,9 @@ export class Inspector extends InjectEvent { } case "number": { const info = new NumberData(propertyValue); + if (typeof key === "string") { + info.step = this.getStep(node, key); + } return make(info); } case "string": { diff --git a/cc-inspector/src/views/devtools/data.ts b/cc-inspector/src/views/devtools/data.ts index 2c7cf68..3cffd06 100644 --- a/cc-inspector/src/views/devtools/data.ts +++ b/cc-inspector/src/views/devtools/data.ts @@ -323,6 +323,7 @@ export class StringData extends Info { export class NumberData extends Info { public data: number = 0; + public step: number = 1; constructor(data: number = 0) { super(); this.type = DataType.Number; @@ -331,6 +332,7 @@ export class NumberData extends Info { parse(data: NumberData) { super.parse(data); this.data = data.data; + this.step = data.step || 1; return this; } public isNumber(): boolean { diff --git a/cc-inspector/src/views/devtools/ui/ui-prop.vue b/cc-inspector/src/views/devtools/ui/ui-prop.vue index 443068a..898cdc9 100644 --- a/cc-inspector/src/views/devtools/ui/ui-prop.vue +++ b/cc-inspector/src/views/devtools/ui/ui-prop.vue @@ -7,7 +7,7 @@ - +
@@ -50,7 +50,6 @@ export default defineComponent({ icon: { type: Boolean, default: true }, headWidth: { type: String, default: "120px" }, arrow: { type: Boolean, default: false }, - step: { type: Number, default: 1 }, value: { type: Object as PropType, default: () => new Info(), @@ -139,6 +138,13 @@ export default defineComponent({ const data = toRaw(props.value.path); bridge.send(Msg.RequestLogData, data as RequestLogData); }, + getStep() { + if (props.value instanceof NumberData) { + return props.value.step || 1; + } else { + return 1; + } + }, }; }, });