From d081c60b051590a5cf5ba921707ad8c3849d82be Mon Sep 17 00:00:00 2001 From: SmallMain Date: Fri, 17 Jun 2022 18:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/settings/builder.json | 2 +- .../inspectors/comps/richtext.js | 7 +- src/creator-sp.d.ts | 90 +++++++++++-------- 3 files changed, 61 insertions(+), 38 deletions(-) diff --git a/demo/settings/builder.json b/demo/settings/builder.json index 4d5fb4e0..85ac2815 100755 --- a/demo/settings/builder.json +++ b/demo/settings/builder.json @@ -9,7 +9,7 @@ "packageName": "org.cocos2d.helloworld", "startScene": "cab4af66-dc74-41b5-8826-79b3a30ba99a", "title": "Cocos-Service-Pack-Demo", - "webOrientation": "auto", + "webOrientation": "landscape", "inlineSpriteFrames": true, "inlineSpriteFrames_native": true, "mainCompressionType": "merge_all_json", diff --git a/extension/service-pack-support/inspectors/comps/richtext.js b/extension/service-pack-support/inspectors/comps/richtext.js index d2328806..568e2679 100644 --- a/extension/service-pack-support/inspectors/comps/richtext.js +++ b/extension/service-pack-support/inspectors/comps/richtext.js @@ -47,7 +47,7 @@ Vue.component("cc-richtext", { :multi-values="multi" > - + @@ -65,6 +65,9 @@ Vue.component("cc-richtext", { T: Editor.T, _isSystemFont() { return this.target.useSystemFont.value - } + }, + _isCharCacheMode() { + return 2 === this.target.cacheMode.value + }, } }); diff --git a/src/creator-sp.d.ts b/src/creator-sp.d.ts index e3bbb4d3..68eebf6f 100644 --- a/src/creator-sp.d.ts +++ b/src/creator-sp.d.ts @@ -144,6 +144,12 @@ declare module cc { */ getEmptyIndex(): number; + + /** + * 自动设置纹理到空插槽,返回插槽下标,失败返回 -1(提供 cc.Texture2D) + */ + autoSetTexture(texture: cc.Texture2D): number; + } /** @@ -175,14 +181,9 @@ declare module cc { /** - * 使 cc.Texture2D 关联指定材质 + * 重置多纹理材质数组,再次使用请先初始化 */ - linkMaterial(texture: cc.Texture2D, handler: MultiHandler, index: number): void; - - /** - * 取消关联 cc.Texture2D 上已关联的材质 - */ - unlinkMaterial(texture: cc.Texture2D): void; + reset(): void; } @@ -249,6 +250,11 @@ declare module cc { */ enableRetina: cc.RenderComponent.EnableType; + /** + * 置渲染数据刷新脏标记 + */ + setVertsDirty(): void; + } namespace Label { @@ -399,6 +405,11 @@ declare module cc { */ allowDynamicAtlas: cc.RenderComponent.EnableType; + /** + * 置渲染数据刷新脏标记 + */ + setVertsDirty(): void; + } interface RichText { @@ -423,6 +434,11 @@ declare module cc { */ enableRetina: cc.RenderComponent.EnableType; + /** + * 置渲染数据刷新脏标记 + */ + setVertsDirty(): void; + } interface MotionStreak { @@ -437,34 +453,10 @@ declare module cc { */ _checkSwitchMaterial(): void; - } - - /** - * 富文本扩展组件 - * - * 因为引擎未提供其 inspector 文件,无法修改组件的 inspector,所以扩展属性通过相应的扩展组件提供 - */ - class RichTextSP extends cc.Component { - /** - * 自定义内部使用的材质 + * 置渲染数据刷新脏标记 */ - customMaterial: cc.Material; - - /** - * 是否自动切换至贴图关联的材质 - */ - autoSwitchMaterial: cc.RenderComponent.EnableType; - - /** - * 参与动态合图 - */ - allowDynamicAtlas: cc.RenderComponent.EnableType; - - /** - * 是否启用渲染时进行缩放以适配高 DPI 屏幕 - */ - enableRetina: cc.RenderComponent.EnableType; + setVertsDirty(): void; } @@ -475,6 +467,29 @@ declare module cc { */ _multiMaterial: cc.Material; + /** + * 关联指定材质,返回是否成功 + * + * @param material 材质 + * @param index 材质纹理插槽下标,默认自动寻找第一个空插槽 + */ + linkMaterial(material: cc.Material, index?: number): boolean; + + /** + * 取消已关联的材质 + */ + unlinkMaterial(): void; + + /** + * 获取已关联的材质 + */ + getLinkedMaterial(): cc.Material; + + /** + * 是否已关联材质 + */ + hasLinkedMaterial(): boolean; + } interface Material { @@ -556,7 +571,7 @@ declare module cc { /** * 已使用数量 */ - _count; + _count: number; /** * cc.RenderTexture @@ -681,7 +696,7 @@ declare module cc { /** * cc.Texture2D UUID */ - uuid: cc.Texture2D; + uuid: string; /** * 使用该贴图的精灵帧数组 @@ -829,6 +844,11 @@ declare module sp { */ setRegion(slotName: string, attachmentName: string, region: spine.TextureRegion): boolean; + /** + * 置渲染数据刷新脏标记 + */ + setVertsDirty(): void; + } }