From 17d3cc968ea5b7fe7b9cb960c0821236c0c2c74d Mon Sep 17 00:00:00 2001 From: gongxh Date: Fri, 9 May 2025 21:48:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9creator3.7+=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ README.md | 10 ++++++++-- package.json | 2 +- src/asset/AssetPool.ts | 2 +- src/cocos/CocosAdapter.ts | 29 +++++++++++++++++------------ src/cocos/CocosUIModule.ts | 3 ++- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa88c7..2fd4be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,3 +16,5 @@ - 修复热更新manifest文件cdn缓存导致检测不到更新的问题 ## 1.0.33 - UI模块添加fgui控制器和动画装饰器,详情见 [UI模块](./docs/UI.md) +## 1.0.34 +- 兼容性修改,兼容creator3.7及之后的版本 diff --git a/README.md b/README.md index 0499198..148b8b7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ # KunpoLib -基于 Cocos Creator 3.0+ 的一套游戏框架,提供了一系列实用模块,帮助开发者快速构建高质量的游戏项目。 +基于 Cocos Creator 的一套游戏框架,提供了一系列实用模块,帮助开发者快速构建高质量的游戏项目。 项目持续优化中,敬请期待~~~ + +#### 版本支持 +- creator 3.7之前的版本理论上也支持,未测试 +- creator 3.7+ 支持 +- creator 3.8+ 支持 + > 此项目是框架源码,不是creator项目 > > demo见最下方仓库地址 @@ -66,7 +72,7 @@ gongxh * 邮箱: gong.xinhai@163.com ## 仓库 -[kunpocc gitree地址](https://gitee.com/gongxinhai/kunpolibrary) +[kunpocc gitee地址](https://gitee.com/gongxinhai/kunpolibrary) [kunpocc github地址](https://github.com/Gongxh0901/kunpolibrary) diff --git a/package.json b/package.json index 3b5d02e..4371cac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kunpocc", - "version": "1.0.33", + "version": "1.0.34", "description": "基于creator3.0+的kunpocc库", "main": "./dist/kunpocc.cjs", "module": "./dist/kunpocc.mjs", diff --git a/src/asset/AssetPool.ts b/src/asset/AssetPool.ts index f4d97c0..3e356db 100644 --- a/src/asset/AssetPool.ts +++ b/src/asset/AssetPool.ts @@ -32,7 +32,7 @@ export class AssetPool { this.add(item, bundle, batchName); } } else { - let uuid = asset.uuid; + let uuid = asset.uuid || asset._uuid; if (this._uuidToName.has(uuid)) { return; } diff --git a/src/cocos/CocosAdapter.ts b/src/cocos/CocosAdapter.ts index d0611c7..83b06f2 100644 --- a/src/cocos/CocosAdapter.ts +++ b/src/cocos/CocosAdapter.ts @@ -38,17 +38,22 @@ export class CocosAdapter extends Adapter { * @internal */ protected registerResizeCallback(callback: (...args: any) => void): void { - ccScreen.on("window-resize", (...args: any) => { - debug("window-resize"); - callback(...args); - }, this); - ccScreen.on("orientation-change", (...args: any) => { - debug("orientation-change"); - callback(...args); - }, this); - ccScreen.on("fullscreen-change", (...args: any) => { - debug("fullscreen-change"); - callback(...args); - }, this); + if (ccScreen && ccScreen.on) { + ccScreen.on("window-resize", (...args: any) => { + debug("window-resize"); + callback(...args); + }, this); + ccScreen.on("orientation-change", (...args: any) => { + debug("orientation-change"); + callback(...args); + }, this); + ccScreen.on("fullscreen-change", (...args: any) => { + debug("fullscreen-change"); + callback(...args); + }, this); + } else { + // 3.8.0之前的版本 + view.setResizeCallback(callback); + } } } diff --git a/src/cocos/CocosUIModule.ts b/src/cocos/CocosUIModule.ts index d041134..ae675c8 100644 --- a/src/cocos/CocosUIModule.ts +++ b/src/cocos/CocosUIModule.ts @@ -3,10 +3,11 @@ * @Date: 2024-12-07 * @Description: cocos UI模块 */ -import { _decorator, debug } from "cc"; +import { _decorator } from "cc"; import { GRoot } from "fairygui-cc"; import { ModuleBase } from "../module/ModuleBase"; +import { debug } from "../tool/log"; import { WindowManager } from "../ui/WindowManager"; import { WindowResPool } from "../ui/WindowResPool"; import { CocosWindowContainer } from "./CocosWindowContainer";