mirror of
https://github.com/szrpf/DataBoardDemo.git
synced 2025-11-03 04:45:43 +00:00
v2.0
This commit is contained in:
@@ -598,7 +598,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "f8ojtV5RxJyppxJXTwvRbA"
|
||||
"_id": "b8IxWUbGBN4ZAK2hGc0mte"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -660,7 +660,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "28JdLs6QFKdplow4Vcop4h"
|
||||
"_id": "c7vtJRZAJCQ4T0beA4GE98"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -690,7 +690,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "6a5nzBAKFG/Y3sA2e8abM6"
|
||||
"_id": "c6k8j1YNNLH6iOBrpdN3kJ"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -752,7 +752,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "96kbAXXyNK1akIGWmV2D4E"
|
||||
"_id": "9aN+10CXdOSY8LkytqGrCE"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -782,7 +782,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "c634mO6m9DAoGcrT9u7GG3"
|
||||
"_id": "66/N4fj+xMs5LA1EZkAegh"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -844,7 +844,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "fbmT0N5IlBPaXEuSFKjmJS"
|
||||
"_id": "97SVMRHiZESKvhs6O6T+F6"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -874,7 +874,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "d4fxTpMidJcZF86bFkr4G1"
|
||||
"_id": "0dYOQeFA1EubrzVCvgNCHr"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -904,8 +904,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 592.22,
|
||||
"height": 678.72
|
||||
"width": 651,
|
||||
"height": 462.72
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -939,7 +939,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "75V74ndIVEt4kNrIEmp+Wg"
|
||||
"_id": "abSX/4O+BGeKHeujiB3wJM"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
@@ -956,8 +956,8 @@
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_string": "坐标:\t0,\t50\n角度:\t80°,\t弧度:\t0π\n世界坐标:\t(540,\t1010)\nhp:\t100 \t \t \tmp:\t60\n变换矩阵\n\t\t\t0\t\t-1\t\t\t0\t\t\t540\n\t\t\t1\t\t\t0\t\t\t0\t\t\t1010\n\t\t\t0\t\t\t0\t\t\t1\t\t\t0\n\t\t\t0\t\t\t0\t\t\t0\t\t\t1",
|
||||
"_N$string": "坐标:\t0,\t50\n角度:\t80°,\t弧度:\t0π\n世界坐标:\t(540,\t1010)\nhp:\t100 \t \t \tmp:\t60\n变换矩阵\n\t\t\t0\t\t-1\t\t\t0\t\t\t540\n\t\t\t1\t\t\t0\t\t\t0\t\t\t1010\n\t\t\t0\t\t\t0\t\t\t1\t\t\t0\n\t\t\t0\t\t\t0\t\t\t0\t\t\t1",
|
||||
"_string": "坐标:\t0.0,\t50.0\n角度:\t80.0°,\t弧度:\t0.4π\n世界坐标:\t540.0,\t1010.0\nhp:\t100.0\t\t\t\t\t\tmp:\t60.0\n小刀\n5.0",
|
||||
"_N$string": "坐标:\t0.0,\t50.0\n角度:\t80.0°,\t弧度:\t0.4π\n世界坐标:\t540.0,\t1010.0\nhp:\t100.0\t\t\t\t\t\tmp:\t60.0\n小刀\n5.0",
|
||||
"_fontSize": 60,
|
||||
"_lineHeight": 72,
|
||||
"_enableWrapText": true,
|
||||
@@ -972,7 +972,7 @@
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 0,
|
||||
"_N$cacheMode": 0,
|
||||
"_id": "e3V1vuYdNIJJ/UR4RFFYQo"
|
||||
"_id": "13p4urwflHk7m1T9Vqj5+5"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.LabelOutline",
|
||||
@@ -990,7 +990,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_width": 6,
|
||||
"_id": "8c+vc5pnVMCZbBEgPSGytG"
|
||||
"_id": "f9RKPbYmBJLqgnT16oJjtk"
|
||||
},
|
||||
{
|
||||
"__type__": "9285eM4YhBJhL8+C569X294",
|
||||
@@ -1030,7 +1030,7 @@
|
||||
"_collideBoxOpacity": 100,
|
||||
"_isCustomLabelActive": true,
|
||||
"customComponentName": "Hero",
|
||||
"_customLabelString": "坐标:x,y\n角度:angle,弧度:radian\n世界坐标:wp\nhp:#hp mp:#mp\n变换矩阵\nmatrix",
|
||||
"_customLabelString": "坐标:x,y\n角度:angle,弧度:radian\n世界坐标:wp\nhp:#hp mp:#mp\n#equip.sword\n#equip.shoe.attr.speed",
|
||||
"_customLabelOffset": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
@@ -1044,7 +1044,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_customLabelSize": 60,
|
||||
"_customLabelDigit": 0,
|
||||
"_customLabelDigit": 1,
|
||||
"_id": "f4qvGlRGRDaZMkdYB8uWAL"
|
||||
},
|
||||
{
|
||||
@@ -1075,7 +1075,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 714.85,
|
||||
"width": 713,
|
||||
"height": 268.8
|
||||
},
|
||||
"_anchorPoint": {
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
* 自定义参数: 节点自身属性,以及节点任意脚本中的属性
|
||||
* 锚点: 锚点位置会显示一个小红点
|
||||
* 自定义参数(配置想监控的数据):
|
||||
* wp: 世界坐标,即相对于屏幕左下角的坐标
|
||||
* radian: 节点弧度,单位π
|
||||
* wp: 世界坐标
|
||||
* radian: 节点弧度(单位:π)
|
||||
* matrix: 变换矩阵
|
||||
* parent: 父节点
|
||||
* children: 子节点
|
||||
* 自身属性: scale,width,opacity等
|
||||
* 自身属性: x,y,parent,children等
|
||||
* 脚本属性: 脚本实例对象的属性
|
||||
* ↓↓参数可以用3种分隔符隔开↓↓
|
||||
* 英文逗号、英文冒号、空格
|
||||
@@ -93,13 +91,13 @@ export default class DataBoard extends cc.Component {
|
||||
private customComponentName: string = '';
|
||||
@property
|
||||
private _customLabelString: string = 'x,y';
|
||||
@property({ multiline: true, displayName: CC_DEV && '······参数', tooltip: CC_DEV && "—————支持的参数————\nwp:世界坐标\nradian:角度(单位:π)\nmatrix:变换矩阵\nparent:父节点\nchildren:子节点\n自身属性:scale,width,opacity等\n脚本属性:脚本实例对象的属性\n↓↓参数可以用3种分隔符隔开↓↓\n英文逗号、英文冒号、空格\n————举个栗子————\n脚本:Hero\n参数:wp,scale,angle,#angle,#hp\n显示结果:\n世界坐标,节点scale,节点angle,Hero对象的angle,Hero对象的hp\n————温馨提示————\n初始化的时候,设置全局变量\nwindow['DATABOARD'] = false\n可屏蔽本项目所有DataBoard,不会产生任何额外开销", visible() { return this.isCustomLabelActive } })
|
||||
@property({ multiline: true, displayName: CC_DEV && '······参数', tooltip: CC_DEV && "—————支持的参数————\nwp:世界坐标\nradian:节点弧度(单位:π)\nmatrix:变换矩阵\n自身属性:x,y,parent,children等\n脚本属性:脚本实例对象的属性\n↓↓参数可以用3种分隔符隔开↓↓\n英文逗号、英文冒号、空格\n————举个栗子————\n脚本:Hero\n参数:wp,scale,angle,#angle,#hp\n显示结果:\n世界坐标,节点scale,节点angle,Hero对象的angle,Hero对象的hp\n————温馨提示————\n初始化的时候,设置全局变量\nwindow['DATABOARD'] = false\n可屏蔽本项目所有DataBoard,不会产生任何额外开销", visible() { return this.isCustomLabelActive } })
|
||||
private get customLabelString() { return this._customLabelString };
|
||||
private set customLabelString(value: string) {
|
||||
this._customLabelString = value;
|
||||
this.customLabelStringSplit = value
|
||||
.replace(/,/g, '_~_').replace(/:/g, '_!_').replace(/ /g, '_@_')
|
||||
.replace(/(?<!_)\n/g, '_\n').replace(/\n(?!_)/g, '\n_').split('_');
|
||||
.replace(/_*\n_*/g, '_\n_').split('_');
|
||||
}
|
||||
@property
|
||||
private _customLabelOffset: cc.Vec2 = cc.v2(0, 100);
|
||||
@@ -246,8 +244,8 @@ export default class DataBoard extends cc.Component {
|
||||
let tmp = null;
|
||||
switch (strs[i]) {
|
||||
case 'wp':
|
||||
let pos = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
|
||||
tmp = `(${pos.x.toFixed(this.customLabelDigit)},\t${pos.y.toFixed(this.customLabelDigit)})`;
|
||||
let matrix = this.node['_worldMatrix'].m;
|
||||
tmp = `${matrix[12].toFixed(this.customLabelDigit)},\t${matrix[13].toFixed(this.customLabelDigit)}`;
|
||||
break;
|
||||
case 'angle':
|
||||
tmp = this.node.angle.toFixed(this.customLabelDigit) + '°';
|
||||
@@ -256,50 +254,58 @@ export default class DataBoard extends cc.Component {
|
||||
tmp = (this.node.angle / 180).toFixed(this.customLabelDigit) + 'π';
|
||||
break;
|
||||
case 'matrix':
|
||||
let matrix = this.node['_worldMatrix'].m;
|
||||
matrix = this.node['_worldMatrix'].m;
|
||||
tmp = '';
|
||||
for (let i = 0; i < 4; ++i) {
|
||||
for (let j = 0; j < 4; ++j) {
|
||||
let mm = matrix[j * 4 + i];
|
||||
tmp += (mm < 0 ? '\t\t' : '\t\t\t') + mm.toFixed(this.customLabelDigit);
|
||||
let m = matrix[j * 4 + i];
|
||||
tmp += (m < 0 ? '\t\t' : '\t\t\t') + m.toFixed(this.customLabelDigit);
|
||||
}
|
||||
if (i !== 3) tmp += '\n';
|
||||
i !== 3 && (tmp += '\n');
|
||||
}
|
||||
break;
|
||||
case 'parent':
|
||||
tmp = this.node.parent.name;
|
||||
break;
|
||||
case 'children':
|
||||
tmp = '';
|
||||
for (let i = 0, len = this.node.childrenCount; i < len; ++i) {
|
||||
tmp += `\t\t\t${i}:${this.node.children[i].name}`;
|
||||
if (i !== len - 1) tmp += '\n';
|
||||
i !== len - 1 && (tmp += '\n');
|
||||
}
|
||||
break;
|
||||
case '~': tmp = ',\t'; break;
|
||||
case '!': tmp = ':\t'; break;
|
||||
case '@': tmp = ' \t'; break;
|
||||
case '@': tmp = '\t\t'; break;
|
||||
default:
|
||||
if (this.node[strs[i]] !== undefined) {
|
||||
tmp = this.node[strs[i]];
|
||||
} else if (strs[i].startsWith('#') && this.monitorComp !== null) {
|
||||
tmp = this.monitorComp[strs[i].substring(1)];
|
||||
tmp = this.parseString(strs[i].substring(1));
|
||||
} else {
|
||||
tmp = strs[i];
|
||||
}
|
||||
if (tmp && tmp.name) {
|
||||
if (typeof tmp === 'number') {
|
||||
tmp = tmp.toFixed(this.customLabelDigit);
|
||||
} else if (tmp.name) {
|
||||
tmp = tmp.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (typeof tmp === 'number') {
|
||||
tmp = tmp.toFixed(this.customLabelDigit);
|
||||
}
|
||||
str += tmp;
|
||||
}
|
||||
this.customLabel.string = str;
|
||||
}
|
||||
|
||||
private parseString(str: string) {
|
||||
let strs = str.split('.');
|
||||
let ret = this.monitorComp[strs[0]] || `#${strs[0]}`;
|
||||
for (let i = 1, len = strs.length; i < len; ++i) {
|
||||
if (ret[strs[i]] === undefined) {
|
||||
return `${ret.name ? ret.name : ret}.${strs[i]}`;
|
||||
}
|
||||
ret = ret[strs[i]];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected onDestroy() {
|
||||
if (cc.isValid(this.boardNode)) {
|
||||
this.boardNode.removeFromParent();
|
||||
|
||||
Reference in New Issue
Block a user