mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 08:28:41 +00:00
This commit is contained in:
parent
46d06e4b8e
commit
5c79c3a16c
@ -46,18 +46,45 @@ function getButton(node: any, fillFn: boolean): FunctionInfo[] {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCallbacks(node: any, code: ShowCode, fillFn: boolean = false): FunctionInfo[] {
|
export function getCallbacks(node: any, code: ShowCode, fillFn: boolean, v2: boolean): FunctionInfo[] {
|
||||||
if (node instanceof cc.Scene) {
|
if (node instanceof cc.Scene) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (code === ShowCode.ButtonClickEvents) {
|
if (code === ShowCode.ButtonClickEvents) {
|
||||||
return getButton(node, fillFn);
|
return getButton(node, fillFn);
|
||||||
} else {
|
} else {
|
||||||
return getTouch(node, code, fillFn);
|
if (v2) {
|
||||||
|
return getTouchV2(node, code, fillFn);
|
||||||
|
} else {
|
||||||
|
return getTouchV3(node, code, fillFn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function getTouch(node: any, code: ShowCode, fillFn: boolean = false): FunctionInfo[] {
|
function getTouchV2(node: any, code: ShowCode, fillFn: boolean): FunctionInfo[] {
|
||||||
|
const key = getKey(code);
|
||||||
|
if (!key) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!node._bubblingListeners) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!node._bubblingListeners._callbackTable) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const tables = node._bubblingListeners._callbackTable[key];
|
||||||
|
if (!tables) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const infos: Array<any> = tables.callbackInfos;
|
||||||
|
if (!infos || infos.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return infos.map((fun) => {
|
||||||
|
// @ts-ignore
|
||||||
|
return getFn(fun.callback, fillFn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getTouchV3(node: any, code: ShowCode, fillFn: boolean): FunctionInfo[] {
|
||||||
const key = getKey(code);
|
const key = getKey(code);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return [];
|
return [];
|
||||||
@ -97,11 +124,11 @@ function getFn(item: Function, fillFn: boolean): FunctionInfo {
|
|||||||
}
|
}
|
||||||
export const ANONYMOUS = "anonymous";
|
export const ANONYMOUS = "anonymous";
|
||||||
|
|
||||||
export function calcCodeHint(node: any, data: TreeData) {
|
export function calcCodeHint(node: any, data: TreeData, v2: boolean) {
|
||||||
data.codeTouchStart = getCallbacks(node, ShowCode.TouchStart);
|
data.codeTouchStart = getCallbacks(node, ShowCode.TouchStart, false, v2);
|
||||||
data.codeTouchMove = getCallbacks(node, ShowCode.TouchMove);
|
data.codeTouchMove = getCallbacks(node, ShowCode.TouchMove, false, v2);
|
||||||
data.codeTouchEnd = getCallbacks(node, ShowCode.TouchEnd);
|
data.codeTouchEnd = getCallbacks(node, ShowCode.TouchEnd, false, v2);
|
||||||
data.codeTouchCancel = getCallbacks(node, ShowCode.TouchCancel);
|
data.codeTouchCancel = getCallbacks(node, ShowCode.TouchCancel, false, v2);
|
||||||
data.codeButtonClick = getCallbacks(node, ShowCode.ButtonClick);
|
data.codeButtonClick = getCallbacks(node, ShowCode.ButtonClick, false, v2);
|
||||||
data.codeButtonEvents = getCallbacks(node, ShowCode.ButtonClickEvents);
|
data.codeButtonEvents = getCallbacks(node, ShowCode.ButtonClickEvents, false, v2);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ export class Inspector extends InjectEvent {
|
|||||||
if (!node || !node.isValid) {
|
if (!node || !node.isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const funArray = getCallbacks(node, data.code, true);
|
const funArray = getCallbacks(node, data.code, true, this.isCreatorV2());
|
||||||
if (funArray && funArray.length && data.index < funArray.length) {
|
if (funArray && funArray.length && data.index < funArray.length) {
|
||||||
const item = funArray[data.index];
|
const item = funArray[data.index];
|
||||||
this.target = item.fn;
|
this.target = item.fn;
|
||||||
@ -337,7 +337,8 @@ export class Inspector extends InjectEvent {
|
|||||||
data.text = node.name;
|
data.text = node.name;
|
||||||
data.icon = this.calcIcon(node);
|
data.icon = this.calcIcon(node);
|
||||||
data.color = this.calcColor(node);
|
data.color = this.calcColor(node);
|
||||||
calcCodeHint(node, data);
|
const v2 = this.isCreatorV2();
|
||||||
|
calcCodeHint(node, data, v2);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (node instanceof cc.Scene) {
|
if (node instanceof cc.Scene) {
|
||||||
// 场景不允许获取active,引擎会报错
|
// 场景不允许获取active,引擎会报错
|
||||||
|
Loading…
x
Reference in New Issue
Block a user