2022-03-31 00:57:26 +00:00
|
|
|
"use strict";
|
|
|
|
let fs = require("fs");
|
|
|
|
let path = require("path");
|
2022-08-18 04:09:30 +00:00
|
|
|
const EditorAPI = require('./src/main/editor-api');
|
2022-03-31 00:57:26 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2022-08-18 04:09:30 +00:00
|
|
|
/**
|
|
|
|
* 獲取場景節點下的配置信息
|
|
|
|
* @param event event
|
|
|
|
* @param data 這邊把panel的Node帶進來
|
|
|
|
*/
|
|
|
|
"replaceResource": function (event, request) {
|
|
|
|
let self = this;
|
|
|
|
var response = null;
|
|
|
|
var args = request.args;
|
|
|
|
try {
|
|
|
|
let uuid1 = args[0];
|
|
|
|
let uuid2 = args[1];
|
|
|
|
let uuid3 = args[2];
|
|
|
|
let path = Editor.assetdb.uuidToUrl(uuid3);
|
|
|
|
// let assetInfo = EditorAPI.assetInfoByUuid(uuid1);
|
|
|
|
Editor.log(`path: ${path}`);
|
|
|
|
// Editor.log(`node: ${JSON.stringify(assetInfo)}`);
|
|
|
|
// let Version_path = Version_assetInfo.path;
|
|
|
|
// Editor.log("Version_path: " + Version_path);
|
|
|
|
// let Version = fs.readFileSync(Version_path, "utf8"); // 讀取檔案
|
|
|
|
// Editor.log(`uuid3: ${uuid3}`);
|
|
|
|
// Editor.assetdb.queryInfoByUuid(uuid1, function (err, info) {
|
|
|
|
// Editor.log(`path: ${info.path}`);
|
|
|
|
// Editor.log(`url: ${info.url}`);
|
|
|
|
// Editor.log(`type: ${info.type}`);
|
|
|
|
// // Editor.assetdb.queryAssets(info.url, info.type, function (err, info) {
|
|
|
|
// // Editor.log(`info: ${JSON.stringify(info)}`);
|
|
|
|
// // });
|
|
|
|
// });
|
2022-03-31 00:57:26 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
// Editor.Selection.select('asset', uuid1);
|
|
|
|
// Editor.Selection.clear('node')
|
|
|
|
// let nodeUuids = Editor.Selection.curSelection("node");
|
|
|
|
// Editor.Ipc.sendToPanel("scene", "scene:create-nodes-by-uuids", [uuid1], nodeUuids, { unlinkPrefab: null })
|
|
|
|
// Editor.Selection.select('node', uuid1)
|
|
|
|
// nodeUuids = Editor.Selection.curSelection("node");
|
2022-03-31 00:57:26 +00:00
|
|
|
|
2022-08-18 04:09:30 +00:00
|
|
|
// let source = cc.find("SlotPaytable_66");
|
|
|
|
// // 修改运行中的节点属性:
|
|
|
|
// Editor.Ipc.sendToPanel('scene', 'scene:set-property', {
|
|
|
|
// id: uuid1,
|
|
|
|
// path: "name",//要修改的属性
|
|
|
|
// type: "String",
|
|
|
|
// value: "8787",
|
|
|
|
// isSubProp: false,
|
|
|
|
// });
|
|
|
|
// Editor.log(`node: ${JSON.stringify(source)}`);
|
|
|
|
// Editor.log(`node: ${source}`);
|
|
|
|
|
|
|
|
// response = JSON.stringify(res);
|
|
|
|
} catch (error) {
|
|
|
|
Editor.error(`replaceResource error: ${error}`);
|
|
|
|
}
|
|
|
|
response = "666";
|
|
|
|
if (event.reply) {
|
|
|
|
event.reply(null, response);
|
|
|
|
}
|
|
|
|
},
|
2022-03-31 00:57:26 +00:00
|
|
|
};
|