mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-15 22:51:03 +00:00
优化部分属性的step为0.1
This commit is contained in:
parent
570cc2a773
commit
554e60cdff
@ -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<string>): 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": {
|
||||
|
@ -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 {
|
||||
|
@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<CCInput v-if="value.isString()" v-model:value="value.data" :disabled="value.readonly" @change="onChangeValue"> </CCInput>
|
||||
<CCTextarea v-if="value.isText()" v-model:value="value.data" :disabled="value.readonly" @change="onChangeValue"> </CCTextarea>
|
||||
<CCInputNumber v-if="value.isNumber()" v-model:value="value.data" :step="step" :disabled="value.readonly" @change="onChangeValue"></CCInputNumber>
|
||||
<CCInputNumber v-if="value.isNumber()" v-model:value="value.data" :step="getStep()" :disabled="value.readonly" @change="onChangeValue"></CCInputNumber>
|
||||
<div v-if="value.isVec2() || value.isVec3() || value.isVec4()" class="vec">
|
||||
<UiProp v-for="(vec, index) in value.data" :icon="!!index" head-width="auto" :key="index" :arrow="false" :value="vec.value" :name="vec.name"> </UiProp>
|
||||
</div>
|
||||
@ -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<Info | EngineData | EnumData | NumberData | StringData | TextData | Vec2Data | Vec3Data | ImageData>,
|
||||
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;
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user