适配v3版本的step功能

This commit is contained in:
xu_yanfeng 2025-01-28 13:14:53 +08:00
parent 554e60cdff
commit ee0f22bec8
4 changed files with 35 additions and 7 deletions

View File

@ -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);

View File

@ -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,
});

View File

@ -16,6 +16,7 @@ export interface BuildArrayOptions {
export interface BuildVecOptions {
path: string[];
keys: string[];
step?: number;
ctor: Function;
value: Object;
data: Vec3Data | Vec2Data;

View File

@ -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",