mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-05-31 05:14:02 +00:00
和Inspect插件联动,打开预制体和场景
This commit is contained in:
parent
16f100cbd1
commit
07fc5c874c
@ -157,6 +157,7 @@ export enum Msg {
|
||||
RequestOpenScript = "request-open-script",
|
||||
RequestBreakOn = "request-break-on",
|
||||
RequestBreakClean = "request-break-clean",
|
||||
RequestOpenInCocos = "request-open-in-cocos",
|
||||
}
|
||||
export enum BreakOnType {
|
||||
SizeChanged = "size changed",
|
||||
|
29
src/scripts/inject/everything.ts
Normal file
29
src/scripts/inject/everything.ts
Normal file
@ -0,0 +1,29 @@
|
||||
// 和everything插件交互
|
||||
export class Everything {
|
||||
// 支持多开creator,遍历everything插件的server
|
||||
|
||||
test() {
|
||||
const port = 2505;
|
||||
fetch(`http://localhost:${port}/test`)
|
||||
.then((e) => {})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
open(prefabUUID: string) {
|
||||
console.log("open prefab:", prefabUUID);
|
||||
// const url = new URL(window.location.href);
|
||||
// const port = Number(url.port) - 1000 || 7456;
|
||||
const port = 2505; // 暂时拿不到编辑器api,暂时写死
|
||||
const url = `http://localhost:${port}/open?uuid=${prefabUUID}`;
|
||||
// console.log("open url:", url);
|
||||
fetch(url)
|
||||
.then((e) => {
|
||||
console.log(e);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
export const everything = new Everything();
|
@ -3,16 +3,17 @@ import { uniq } from "lodash";
|
||||
import { BreakOnType, Msg, PluginEvent, RequestBreakOnData, RequestLogData, RequestNodeInfoData, RequestOpenNodeTouchFuntionData, RequestOpenScriptData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||
import { CompType, getNodeIcon } from "../../views/devtools/comp";
|
||||
import { ArrayData, BoolData, ColorData, DataType, EngineData, EnumData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectCircleData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../../views/devtools/data";
|
||||
import { addBreak, cleanBreak } from "./break";
|
||||
import { calcCodeHint, getCallbacks } from "./code-hint";
|
||||
import { getEnumListConfig } from "./enumConfig";
|
||||
import { InjectEvent } from "./event";
|
||||
import { everything } from "./everything";
|
||||
import { Hint } from "./hint";
|
||||
import { injectView } from "./inject-view";
|
||||
import { inspectTarget } from "./inspect-list";
|
||||
import { getValue, trySetValueWithConfig } from "./setValue";
|
||||
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
|
||||
import { isHasProperty } from "./util";
|
||||
import { addBreak, cleanBreak } from "./break";
|
||||
|
||||
declare const cc: any;
|
||||
export class Inspector extends InjectEvent {
|
||||
@ -257,6 +258,23 @@ export class Inspector extends InjectEvent {
|
||||
console.log(`not adapt event: ${data.type}`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Msg.RequestOpenInCocos: {
|
||||
const uuid: string = pluginEvent.data;
|
||||
const node = this.inspectorGameMemoryStorage[uuid];
|
||||
if (node && node.isValid) {
|
||||
console.log(node.uuid, node);
|
||||
let prefabUUID = "";
|
||||
if (node instanceof cc.Scene) {
|
||||
prefabUUID = node.uuid;
|
||||
} else {
|
||||
prefabUUID = node._prefab?.asset?._uuid;
|
||||
}
|
||||
if (prefabUUID) {
|
||||
everything.open(prefabUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,6 +301,18 @@ export default defineComponent({
|
||||
},
|
||||
onMenu(event: MouseEvent, data: TreeData) {
|
||||
const menus: IUiMenuItem[] = [];
|
||||
// 现在只有prefab才会有颜色,暂时可以这么判断
|
||||
if (data && data.color) {
|
||||
menus.push({
|
||||
name: "open",
|
||||
icon: "cocos",
|
||||
callback: (item) => {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, item.name);
|
||||
bridge.send(Msg.RequestOpenInCocos, data.id);
|
||||
},
|
||||
});
|
||||
menus.push({ type: ccui.menu.MenuType.Separator });
|
||||
}
|
||||
if (data) {
|
||||
function doInspect(type: ShowCode, index: number) {
|
||||
bridge.send(Msg.RequestOpenNodeTouchFuntion, { uuid: data.id, code: type, index } as RequestOpenNodeTouchFuntionData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user