mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-16 07:01:03 +00:00
收集游戏动态图集简略信息
This commit is contained in:
parent
d0d2e1b4e6
commit
f014c62f75
@ -43,7 +43,24 @@ export interface ResponseSupportData {
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
|
||||
export class DynamicAtlas {
|
||||
/**
|
||||
* 是否启用动态图集
|
||||
*/
|
||||
enable: boolean = false;
|
||||
atlasCount: number = 0;
|
||||
maxAtlasCount: number = 0;
|
||||
maxFrameSize: number = 0;
|
||||
textureSize: number = 0;
|
||||
textureBleeding: boolean = true;
|
||||
/**
|
||||
* 是否支持在游戏中查看
|
||||
*/
|
||||
supportView: boolean = false;
|
||||
}
|
||||
export class ResponseGameInfoData {
|
||||
public dynamicAtals = new DynamicAtlas();
|
||||
}
|
||||
export type ResponseUpdateFramesData = FrameDetails[];
|
||||
|
||||
export interface RequestUseFrameData {
|
||||
@ -99,6 +116,12 @@ export enum Msg {
|
||||
RequestDestroy = "request-destroy",
|
||||
|
||||
ResponseError = "response-error",
|
||||
|
||||
RequestGameInfo = "request-game-info",
|
||||
ResponseGameInfo = "response-game-info",
|
||||
|
||||
RequestDynamicAtlasView = "request-dynamic-atlas-view",
|
||||
ResponseDynamicAtlasView = "response-dynamic-atlas-view",
|
||||
}
|
||||
|
||||
export class PluginEvent {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// eval 注入脚本的代码,变量尽量使用var,后来发现在import之后,let会自动变为var
|
||||
import { uniq } from "lodash";
|
||||
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||
import { ArrayData, BoolData, ColorData, DataType, EngineData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectCircleData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../../views/devtools/data";
|
||||
import { InjectEvent } from "./event";
|
||||
import { getValue, trySetValueWithConfig } from "./setValue";
|
||||
@ -11,6 +11,10 @@ declare const cc: any;
|
||||
export class Inspector extends InjectEvent {
|
||||
inspectorGameMemoryStorage: Record<string, any> = {};
|
||||
|
||||
private getAtlasViewFunction() {
|
||||
// 之前只有v2版本支持
|
||||
return cc?.dynamicAtlasManager?.showDebug;
|
||||
}
|
||||
onMessage(pluginEvent: PluginEvent): void {
|
||||
switch (pluginEvent.msg) {
|
||||
case Msg.RequestSupport: {
|
||||
@ -22,6 +26,30 @@ export class Inspector extends InjectEvent {
|
||||
this.updateTreeInfo();
|
||||
break;
|
||||
}
|
||||
case Msg.RequestGameInfo: {
|
||||
const ret = new ResponseGameInfoData();
|
||||
const atlasManager = cc?.dynamicAtlasManager || cc.internal?.dynamicAtlasManager || null;
|
||||
if (atlasManager) {
|
||||
ret.dynamicAtals.enable = atlasManager.enabled;
|
||||
ret.dynamicAtals.atlasCount = atlasManager.atlasCount;
|
||||
ret.dynamicAtals.maxAtlasCount = atlasManager.maxAtlasCount;
|
||||
ret.dynamicAtals.maxFrameSize = atlasManager.maxFrameSize;
|
||||
ret.dynamicAtals.textureSize = atlasManager.textureSize;
|
||||
ret.dynamicAtals.textureBleeding = atlasManager.textureBleeding;
|
||||
ret.dynamicAtals.supportView = !!this.getAtlasViewFunction();
|
||||
this.sendMsgToContent(Msg.ResponseGameInfo, ret);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Msg.RequestDynamicAtlasView: {
|
||||
const b = pluginEvent.data as boolean;
|
||||
const cb = this.getAtlasViewFunction();
|
||||
if (cb) {
|
||||
cb(b);
|
||||
this.sendMsgToContent(Msg.ResponseDynamicAtlasView, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Msg.RequestNodeInfo: {
|
||||
const data = pluginEvent.data as RequestNodeInfoData;
|
||||
this.getNodeInfo(data.uuid);
|
||||
@ -91,6 +119,12 @@ export class Inspector extends InjectEvent {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public isCreatorV2() {
|
||||
return this.getEngineVersion().startsWith("2.");
|
||||
}
|
||||
public isCreatorV3() {
|
||||
return this.getEngineVersion().startsWith("3.");
|
||||
}
|
||||
notifySupportGame(b: boolean) {
|
||||
const version = this.getEngineVersion();
|
||||
this.sendMsgToContent(Msg.ResponseSupport, { support: b, msg: "", version } as ResponseSupportData);
|
||||
|
@ -43,6 +43,9 @@ class Bridge implements TestClient {
|
||||
on(msg: Msg, callback: (data: PluginEvent) => void) {
|
||||
this.emitter.on(msg, callback);
|
||||
}
|
||||
off(msg: Msg, callback: (data: PluginEvent) => void) {
|
||||
this.emitter.off(msg, callback);
|
||||
}
|
||||
recv(event: PluginEvent): void {
|
||||
this.emit(event);
|
||||
}
|
||||
|
95
cc-inspector/src/views/devtools/game-info.vue
Normal file
95
cc-inspector/src/views/devtools/game-info.vue
Normal file
@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<div class="game-info">
|
||||
<CCSection name="DynamicAtals">
|
||||
<template v-slot:header>
|
||||
<div style="flex: 1"></div>
|
||||
<div v-if="supportView" @click="onClickAtlasView" title="show dynamic atlas in game" class="iconfont view" :class="showDynamicAtals ? 'icon_view_on' : 'icon_view_off'"></div>
|
||||
</template>
|
||||
<CCProp name="enable" align="left"> <CCCheckBox :disabled="true" :value="dynamicAtalsEnable"></CCCheckBox> </CCProp>
|
||||
<CCProp name="texture bleeding" align="left"> <CCCheckBox :disabled="true" :value="dynamicAtalsTextureBleeding"></CCCheckBox> </CCProp>
|
||||
<CCProp name="atlas count" align="left"> <CCInputNumber :disabled="true" :value="dynamicAtalsCount"></CCInputNumber> </CCProp>
|
||||
<CCProp name="max atlas count" align="left"> <CCInputNumber :disabled="true" :value="dynamicAtalsMaxAtlasCount"></CCInputNumber> </CCProp>
|
||||
<CCProp name="max frame size" align="left"> <CCInputNumber :disabled="true" :value="dynamicAtalsMaxFrameSize"></CCInputNumber> </CCProp>
|
||||
<CCProp name="atlas texture size" align="left"> <CCInputNumber :disabled="true" :value="dynamicAtalsTextureSize"></CCInputNumber> </CCProp>
|
||||
</CCSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import ccui from "@xuyanfeng/cc-ui";
|
||||
import { defineComponent, onMounted, onUnmounted, ref, toRaw } from "vue";
|
||||
import { Msg, PluginEvent, ResponseGameInfoData } from "../../core/types";
|
||||
import { bridge } from "./bridge";
|
||||
const { CCProp, CCCheckBox, CCSection, CCInputNumber } = ccui.components;
|
||||
export default defineComponent({
|
||||
name: "game-info",
|
||||
components: { CCProp, CCCheckBox, CCSection, CCInputNumber },
|
||||
setup() {
|
||||
function onGameInfo(data: PluginEvent) {
|
||||
const gameInfo = data.data as ResponseGameInfoData;
|
||||
dynamicAtalsEnable.value = !!gameInfo.dynamicAtals.enable;
|
||||
dynamicAtalsCount.value = gameInfo.dynamicAtals.atlasCount;
|
||||
dynamicAtalsMaxAtlasCount.value = gameInfo.dynamicAtals.maxAtlasCount;
|
||||
dynamicAtalsMaxFrameSize.value = gameInfo.dynamicAtals.maxFrameSize;
|
||||
dynamicAtalsTextureSize.value = gameInfo.dynamicAtals.textureSize;
|
||||
dynamicAtalsTextureBleeding.value = gameInfo.dynamicAtals.textureBleeding;
|
||||
supportView.value = !!gameInfo.dynamicAtals.supportView;
|
||||
}
|
||||
function onDynamicAtlasView(data: PluginEvent) {
|
||||
const b = data.data as boolean;
|
||||
showDynamicAtals.value = b;
|
||||
}
|
||||
onMounted(() => {
|
||||
bridge.on(Msg.ResponseGameInfo, onGameInfo);
|
||||
bridge.on(Msg.ResponseDynamicAtlasView, onDynamicAtlasView);
|
||||
bridge.send(Msg.RequestGameInfo);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
bridge.off(Msg.ResponseDynamicAtlasView, onDynamicAtlasView);
|
||||
bridge.off(Msg.ResponseGameInfo, onGameInfo);
|
||||
});
|
||||
const dynamicAtalsEnable = ref(true);
|
||||
const dynamicAtalsCount = ref(0);
|
||||
const dynamicAtalsMaxAtlasCount = ref(0);
|
||||
const dynamicAtalsMaxFrameSize = ref(0);
|
||||
const dynamicAtalsTextureSize = ref(0);
|
||||
const dynamicAtalsTextureBleeding = ref(true);
|
||||
const showDynamicAtals = ref(false);
|
||||
const supportView = ref(false);
|
||||
function onClickAtlasView() {
|
||||
const b = toRaw(showDynamicAtals.value);
|
||||
bridge.send(Msg.RequestDynamicAtlasView, !b);
|
||||
}
|
||||
return {
|
||||
supportView,
|
||||
showDynamicAtals,
|
||||
dynamicAtalsEnable,
|
||||
dynamicAtalsCount,
|
||||
dynamicAtalsMaxAtlasCount,
|
||||
dynamicAtalsMaxFrameSize,
|
||||
dynamicAtalsTextureSize,
|
||||
dynamicAtalsTextureBleeding,
|
||||
onClickAtlasView,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.game-info {
|
||||
background-color: rgb(32, 32, 32);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.view {
|
||||
cursor: pointer;
|
||||
margin-right: 5px;
|
||||
font-size: 22px;
|
||||
&:hover {
|
||||
color: white;
|
||||
}
|
||||
&:active {
|
||||
color: rgb(255, 153, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -25,6 +25,7 @@ import { GA_EventName } from "../../ga/type";
|
||||
import { bridge } from "./bridge";
|
||||
import { Bus, BusMsg } from "./bus";
|
||||
import { EngineData, TreeData } from "./data";
|
||||
import GameInfo from "./game-info.vue";
|
||||
import { appStore } from "./store";
|
||||
import { Timer } from "./timer";
|
||||
const { CCTree, CCFootBar, CCDock, CCDialog, CCInput, CCButton, CCInputNumber, CCSelect, CCButtonGroup, CCCheckBox, CCColor, CCDivider } = ccui.components;
|
||||
@ -214,6 +215,16 @@ export default defineComponent({
|
||||
updateTree();
|
||||
},
|
||||
});
|
||||
menus.push({
|
||||
name: "game info",
|
||||
callback() {
|
||||
ga.fireEventWithParam(GA_EventName.MouseMenu, "game info");
|
||||
ccui.dialog.showDialog({
|
||||
comp: GameInfo,
|
||||
title: "Game Info",
|
||||
});
|
||||
},
|
||||
});
|
||||
if (selectedUUID) {
|
||||
menus.push({
|
||||
name: "visible (sapce)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user