diff --git a/cc-inspector/src/ga/index.ts b/cc-inspector/src/ga/index.ts index 3665d88..fe92a41 100644 --- a/cc-inspector/src/ga/index.ts +++ b/cc-inspector/src/ga/index.ts @@ -38,7 +38,11 @@ export class GoogleAnalytics { }, ], } as MeasurementBody), - }); + }) + .then(() => {}) + .catch((e) => { + console.error(e); + }); } public async fireEvent(name: string) { if (!this.isChromeEnv()) { @@ -60,7 +64,11 @@ export class GoogleAnalytics { }, ], } as MeasurementBody), - }); + }) + .then(() => {}) + .catch((e) => { + console.error(e); + }); } async clickButton(btn: GA_Button) { await this.fireEventWithParam(GA_EventName.ButtonClicked, btn); diff --git a/cc-inspector/src/scripts/inject/inspector.ts b/cc-inspector/src/scripts/inject/inspector.ts index ee307b1..87b4d36 100644 --- a/cc-inspector/src/scripts/inject/inspector.ts +++ b/cc-inspector/src/scripts/inject/inspector.ts @@ -416,6 +416,9 @@ export class Inspector extends InjectEvent { let propPath = path.concat(propName); let itemData = this._genInfoData(value, propName, propPath); if (itemData) { + if (itemData instanceof NumberData && options.step !== undefined) { + itemData.step = options.step; + } data.add(new Property(propName, itemData)); } } @@ -472,7 +475,10 @@ export class Inspector extends InjectEvent { } } } - private getStep(node: any, key: string) { + private getStep(node: any, key: string | number) { + if (typeof key !== "string") { + return 1; + } const cfgArray: Array<{ type: any; keys: Array<{ key: string; step: number }> }> = []; if (cc.Node) { cfgArray.push({ @@ -482,9 +488,18 @@ export class Inspector extends InjectEvent { { key: "anchorY", step: 0.1 }, { key: "scaleX", step: 0.1 }, { key: "scaleY", step: 0.1 }, + { key: "scale", step: 0.1 }, + { key: "worldScale", step: 0.1 }, ], }); } + const tr = cc.UITransformComponent || cc.UITransform; + if (tr) { + cfgArray.push({ + type: tr, + keys: [{ key: "anchorPoint", step: 0.1 }], + }); + } for (let i = 0; i < cfgArray.length; i++) { const { type, keys } = cfgArray[i]; if (node instanceof type) { @@ -518,9 +533,7 @@ export class Inspector extends InjectEvent { } case "number": { const info = new NumberData(propertyValue); - if (typeof key === "string") { - info.step = this.getStep(node, key); - } + info.step = this.getStep(node, key); return make(info); } case "string": { @@ -563,6 +576,7 @@ export class Inspector extends InjectEvent { path: path, data: new Vec3Data(), keys: ["x", "y", "z"], + step: this.getStep(node, key), value: propertyValue, }); if (info) { @@ -584,6 +598,7 @@ export class Inspector extends InjectEvent { ctor: cc.Vec2, path: path, data: new Vec2Data(), + step: this.getStep(node, key), keys: ["x", "y"], value: propertyValue, }); diff --git a/cc-inspector/src/scripts/inject/types.ts b/cc-inspector/src/scripts/inject/types.ts index 9ee3357..11bcb26 100644 --- a/cc-inspector/src/scripts/inject/types.ts +++ b/cc-inspector/src/scripts/inject/types.ts @@ -16,6 +16,7 @@ export interface BuildArrayOptions { export interface BuildVecOptions { path: string[]; keys: string[]; + step?: number; ctor: Function; value: Object; data: Vec3Data | Vec2Data; diff --git a/cc-inspector/src/views/devtools/comp/index.ts b/cc-inspector/src/views/devtools/comp/index.ts index d99d90c..4632a06 100644 --- a/cc-inspector/src/views/devtools/comp/index.ts +++ b/cc-inspector/src/views/devtools/comp/index.ts @@ -170,7 +170,11 @@ export function getSimpleProperties(typeName: string): string[] { "worldScale", // "worldRotation",// 渲染有问题,暂时先不支持这个属性 ]; - config[CompType.UITransform] = ["anchor", "size"]; + config[CompType.UITransform] = [ + "anchorPoint", //vec2类型,step会正确处理 + // "anchor",// FIXME: 会被Inspector属性配对,无法正确处理step + "size", + ]; config[CompType.Widget] = [ "left", "right",