@cc-component/cc-ex-component 1.5.7 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -83,6 +83,7 @@ export class ReferenceComponent extends Component {
|
|
|
83
83
|
comList = ["EditBox", "Toggle", "ToggleContainer", "Slider", "Button", "ProgressBar", "YXCollectionView", "TableView"]
|
|
84
84
|
comList2 = ["YXCollectionView", "TableView"]
|
|
85
85
|
comList_base = ["EditBox", "Toggle", "ToggleContainer", "Slider", "Button", "ProgressBar"]
|
|
86
|
+
comListAll = ["EditBox", "Toggle", "ToggleContainer", "Slider", "Button", "ProgressBar", "ScrollView", "PageView", "Animation", 'Sprite', 'Label', 'RichText', 'ParticleSystem2D', 'Skeleton']
|
|
86
87
|
|
|
87
88
|
/** 生成代码基础窗口名称 */
|
|
88
89
|
public baseWindowName = "BaseWindow"
|
|
@@ -146,7 +147,10 @@ export class ReferenceComponent extends Component {
|
|
|
146
147
|
let refData = new CollectorNodeData();
|
|
147
148
|
let name = node.name.replace(this._tag, "").trim();
|
|
148
149
|
refData.key = name;
|
|
150
|
+
|
|
149
151
|
refData.com = (node.getComponent(`cc.${nodeType}`) ?? (node.getComponent(`${nodeType}`) ?? node)) as any;
|
|
152
|
+
// console.log('2--', refData.com.name)
|
|
153
|
+
|
|
150
154
|
this.nodes.push(refData);
|
|
151
155
|
}
|
|
152
156
|
}
|
|
@@ -161,7 +165,12 @@ export class ReferenceComponent extends Component {
|
|
|
161
165
|
while (checkArr.length > 0) {
|
|
162
166
|
let v = checkArr.shift();
|
|
163
167
|
let rc = v.getComponent(ReferenceComponent);
|
|
164
|
-
|
|
168
|
+
|
|
169
|
+
if (rc && rc != this) {
|
|
170
|
+
// arr.push(v);
|
|
171
|
+
// console.log("[MLogger]", v.name, "被引用");
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
165
174
|
arr.push(...v.children.filter(v => {
|
|
166
175
|
const ok = this.isNodeValid(v)
|
|
167
176
|
return ok
|
|
@@ -257,7 +266,7 @@ export class ReferenceComponent extends Component {
|
|
|
257
266
|
|
|
258
267
|
|
|
259
268
|
let bind = `${bind_pix}("${name}"${this.comList2.includes(type) ? event : ""})`
|
|
260
|
-
if (this.skipList.includes(type)) {
|
|
269
|
+
if (this.skipList.includes(type) || !this.comListAll.includes(type)) {
|
|
261
270
|
bind = `${bind_pix}()`
|
|
262
271
|
}
|
|
263
272
|
|
|
@@ -303,7 +312,7 @@ export class ReferenceComponent extends Component {
|
|
|
303
312
|
let key = data.key;
|
|
304
313
|
let name = key[0].toLowerCase() + key.substring(1);
|
|
305
314
|
const type = this.getPropertyType(data.com)
|
|
306
|
-
if (!this.skipList.includes(type)) {
|
|
315
|
+
if ((this.comListAll.includes(type) && !this.skipList.includes(type))) {
|
|
307
316
|
//@ts-ignore
|
|
308
317
|
let line = ` ${name}: ${this.getDataTypeByComponentType(type)};`//`private get ${name}() { return this.rc.get("${key}", ${this.getPropertyType(data.node)}); }`;
|
|
309
318
|
sx += line + "" + (index < this.nodes.length - 1 ? "\n" : "");
|
|
@@ -390,10 +399,14 @@ export class ${className}Window extends ViewModel(${this.baseWindowName}) {${sx.
|
|
|
390
399
|
private getPropertyType(node: Node) {
|
|
391
400
|
if (!EDITOR_NOT_IN_PREVIEW) return;
|
|
392
401
|
if (!node) { return "Node" }
|
|
393
|
-
|
|
394
402
|
//自定义脚本
|
|
395
|
-
let comp = node.getComponent('
|
|
396
|
-
if (comp)
|
|
403
|
+
let comp = node.getComponent('BaseReference');
|
|
404
|
+
if (comp) {
|
|
405
|
+
// const com = node.getComponentsInChildren("BaseReference").pop()
|
|
406
|
+
return js.getClassName(comp);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
|
|
397
410
|
//自定义组件
|
|
398
411
|
if (node.getComponent("Switch")) return "Switch";
|
|
399
412
|
if (node.getComponent("MSlider")) return "MSlider";
|
|
@@ -419,8 +432,8 @@ export class ${className}Window extends ViewModel(${this.baseWindowName}) {${sx.
|
|
|
419
432
|
if (node.getComponent("cc.RichText")) return "RichText";
|
|
420
433
|
if (node.getComponent("cc.ParticleSystem2D")) return "ParticleSystem2D";
|
|
421
434
|
if (node.getComponent("sp.Skeleton")) return "sp.Skeleton";
|
|
422
|
-
|
|
423
|
-
return
|
|
435
|
+
const com = node.getComponentsInChildren(Component).pop()
|
|
436
|
+
return js.getClassName(com).replace('cc.', '');
|
|
424
437
|
}
|
|
425
438
|
|
|
426
439
|
getDataTypeByComponentType(compType: string) {
|
package/assets/core/ViewModel.ts
CHANGED
|
@@ -666,7 +666,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
666
666
|
// const width = 100
|
|
667
667
|
// const height = 163
|
|
668
668
|
// layout.itemSize = math.size(width, height)
|
|
669
|
-
table_collection.layout = data.layout(self)
|
|
669
|
+
table_collection.layout = data.layout?.call(self)
|
|
670
670
|
// 注册列表内需要使用的 cell 节点类型
|
|
671
671
|
// 这个演示是通过编辑器绑定的,可以查看场景内 list 节点里的 register cells 配置
|
|
672
672
|
// this.table_collection.register('cell', () => instantiate('your cell prefab'))
|
|
@@ -696,8 +696,11 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
696
696
|
table_collection.reloadData()
|
|
697
697
|
}
|
|
698
698
|
break;
|
|
699
|
+
case 'cc.Node':
|
|
700
|
+
break;
|
|
699
701
|
default: {
|
|
700
|
-
if (com) console.error(`请检查类型: ${data.type}`);
|
|
702
|
+
// if (com) console.error(`请检查类型: ${data.type}`);
|
|
703
|
+
break
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
706
|
|