From 13d32f36ef263e090b7717dc1fce9d87ea4fca52 Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Fri, 15 Sep 2023 14:19:59 +0800 Subject: [PATCH] remove old attribute & add visible --- cocos/2d/components/label-outline.ts | 5 ----- cocos/2d/components/label-shadow.ts | 7 ------- cocos/2d/components/label.ts | 18 ++++++++++-------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/cocos/2d/components/label-outline.ts b/cocos/2d/components/label-outline.ts index e419da75164..6bbe271b7f1 100644 --- a/cocos/2d/components/label-outline.ts +++ b/cocos/2d/components/label-outline.ts @@ -44,11 +44,6 @@ import { Label } from './label'; @requireComponent(Label) @executeInEditMode export class LabelOutline extends Component { - @serializable - protected _color = new Color(0, 0, 0, 255); - @serializable - protected _width = 2; - /** * @en * Outline color. diff --git a/cocos/2d/components/label-shadow.ts b/cocos/2d/components/label-shadow.ts index 6a85ed25225..074e192cdf2 100644 --- a/cocos/2d/components/label-shadow.ts +++ b/cocos/2d/components/label-shadow.ts @@ -41,13 +41,6 @@ import { Label } from './label'; @requireComponent(Label) @executeInEditMode export class LabelShadow extends Component { - @serializable - protected _color = new Color(0, 0, 0, 255); - @serializable - protected _offset = new Vec2(2, 2); - @serializable - protected _blur = 2; - /** * @en * Shadow color. diff --git a/cocos/2d/components/label.ts b/cocos/2d/components/label.ts index 5e5008a4d88..37003194c46 100644 --- a/cocos/2d/components/label.ts +++ b/cocos/2d/components/label.ts @@ -608,9 +608,10 @@ export class Label extends UIRenderer { ** Outline effect used to change the display, only for system fonts or TTF fonts. ** ** @zh - ** 描边效果组件,用于字体描边,只能用于系统字体。 + ** 描边效果组件,用于字体描边,只能用于系统字体或 ttf 字体。 **/ @editable + @visible(function (this: Label) { return !(this._font instanceof BitmapFont); }) @displayOrder(19) @tooltip('i18n:label.outline_enable') get enableOutline (): boolean { @@ -630,7 +631,7 @@ export class Label extends UIRenderer { * 改变描边的颜色。 */ @editable - @visible(function (this: Label) { return this._enableOutline; }) + @visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); }) @displayOrder(20) @tooltip('i18n:label.outline_color') get outlineColor (): Color { @@ -650,7 +651,7 @@ export class Label extends UIRenderer { * 改变描边的宽度。 */ @editable - @visible(function (this: Label) { return this._enableOutline; }) + @visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); }) @displayOrder(21) @tooltip('i18n:label.outline_width') get outlineWidth (): number { @@ -663,10 +664,11 @@ export class Label extends UIRenderer { } /** - * @en Shadow effect for Label component, only for system fonts or TTF fonts. - * @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。 + * @en Shadow effect for Label component, only for system fonts or TTF fonts. Disabled when cache mode is char. + * @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。在缓存模式为 char 时不可用。 */ @editable + @visible(function (this: Label) { return !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(22) @tooltip('i18n:label.shadow_enable') get enableShadow (): boolean { @@ -686,7 +688,7 @@ export class Label extends UIRenderer { * 阴影的颜色。 */ @editable - @visible(function (this: Label) { return this._enableShadow; }) + @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(23) @tooltip('i18n:label.shadow_color') get shadowColor (): Color { @@ -706,7 +708,7 @@ export class Label extends UIRenderer { * 字体与阴影的偏移。 */ @editable - @visible(function (this: Label) { return this._enableShadow; }) + @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(24) @tooltip('i18n:label.shadow_offset') get shadowOffset (): Vec2 { @@ -726,7 +728,7 @@ export class Label extends UIRenderer { * 阴影的模糊程度。 */ @editable - @visible(function (this: Label) { return this._enableShadow; }) + @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(25) @tooltip('i18n:label.shadow_blur') get shadowBlur (): number {