sourcechange/panel/index.js

82 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2022-03-31 00:59:02 +00:00
let assetPath = "";
let defaultPolygonPath = "assets/";
let polygonNameHeader = "polygon_";
let polygonName = "";
Editor.Panel.extend({
style: `
:host { margin: 5px; }
h2 { color: #f90; }
.bottom {
height: 30px;
}
`,
template: `
<h2 style="text-align:center">Source Change</h2>
<hr />
<div>
1. 把要輸出的節點拉進來<br>
2. 把來源編號跟目標標號輸入好
</div>
<hr />
<div>
要使用的Prefab
<ui-node class="flex-1" type="cc.Node" typename="Node" droppable="node" id="node"></ui-node>
<!-- <ui-asset class="flex-1" type="prefab" typename="prefab" droppable="prefab" id="prefab"></ui-asset> -->
</div>
<hr />
<div>
來源Game ID
<ui-input placeholder="來源Game ID ex: 2003" id="self"></ui-input>
</div>
<div>
目標Game ID
<ui-input placeholder="目標Game ID ex: 2004" id="target"></ui-input>
</div>
<hr />
<div style="text-align:right">
<ui-button id="create" class="green">生成</ui-button>
</div>
`,
$: {
/** Node */
node: "#node",
/** 來源Game ID */
self: "#self",
/** 目標Game */
target: "#target",
/** 生成按鈕 */
create: "#create",
},
ready() {
// Editor.Ipc.sendToMain("sourcechange:panel-load-finish");
this.createBtnClick();
},
/** 保存按鈕點擊事件 */
createBtnClick() {
this.$create.addEventListener("confirm", () => {
if (!this.$node._value) {
Editor.error("請拖曳 Node 到視窗");
return;
} else if (!this.$self._value) {
Editor.error("請輸入來源Game ID");
return;
} else if (!this.$target._value) {
Editor.error("請輸入目標Game ID");
return;
}
Editor.Ipc.sendToMain("sourcechange:create-click", this.$node, this.$self, this.$target);
});
},
messages: {
// "setDefault": function (event, ...agrs) {
// if (event.reply) {
// //if no error, the first argument should be null
// event.reply(null, "Fine, thank you!");
// }
// }
}
});