-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration of outline and shadow to label #16106
Changes from 2 commits
382fff5
8a532e8
cc3aae0
2ec6076
6741339
ec97648
33bc9d1
13d32f3
7aedb0b
7b267d3
362af9b
41bf5c7
590bb88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,7 @@ import { Label } from './label'; | |
* @zh | ||
* 描边效果组件,用于字体描边,只能用于系统字体。 | ||
* | ||
* @example | ||
* ```ts | ||
* import { Node, Label, LabelOutline } from 'cc'; | ||
* // Create a new node and add label components. | ||
* const node = new Node("New Label"); | ||
* const label = node.addComponent(Label); | ||
* const outline = node.addComponent(LabelOutline); | ||
* node.parent = this.node; | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.outlineUsed]] instead. | ||
*/ | ||
@ccclass('cc.LabelOutline') | ||
@help('i18n:cc.LabelOutline') | ||
|
@@ -64,11 +56,7 @@ export class LabelOutline extends Component { | |
* @zh | ||
* 改变描边的颜色。 | ||
* | ||
* @example | ||
* ```ts | ||
* import { Color } from 'cc'; | ||
* outline.color = new Color(0.5, 0.3, 0.7, 1.0); | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.outlineColor]] instead. | ||
*/ | ||
@tooltip('i18n:labelOutline.color') | ||
// @constget | ||
|
@@ -82,7 +70,10 @@ export class LabelOutline extends Component { | |
} | ||
|
||
this._color.set(value); | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.outlineColor = this._color; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -92,10 +83,7 @@ export class LabelOutline extends Component { | |
* @zh | ||
* 改变描边的宽度。 | ||
* | ||
* @example | ||
* ```ts | ||
* outline.width = 3; | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.outlineWidth]] instead. | ||
*/ | ||
@tooltip('i18n:labelOutline.width') | ||
get width (): number { | ||
|
@@ -108,21 +96,39 @@ export class LabelOutline extends Component { | |
} | ||
|
||
this._width = value; | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.outlineWidth = this._width; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.outlineUsed]] instead. | ||
*/ | ||
public onEnable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.outlineUsed = true; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.outlineUsed]] instead. | ||
*/ | ||
public onDisable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.outlineUsed = false; | ||
} | ||
} | ||
|
||
protected _updateRenderData (): void { | ||
/** | ||
* @deprecated since v3.8.2, please use [[Label.outlineUsed]] instead. | ||
*/ | ||
public onLoad (): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems not needs onLoad anymore. |
||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.updateRenderData(true); | ||
if (label && this.enabledInHierarchy) { | ||
label.outlineUsed = true; | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,13 +31,8 @@ import { Label } from './label'; | |
/** | ||
* @en Shadow effect for Label component, only for system fonts or TTF fonts. | ||
* @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。 | ||
* @example | ||
* import { Node, Label, LabelShadow } from 'cc'; | ||
* // Create a new node and add label components. | ||
* const node = new Node("New Label"); | ||
* const label = node.addComponent(Label); | ||
* const shadow = node.addComponent(LabelShadow); | ||
* node.parent = this.node; | ||
* | ||
* @deprecated since v3.8.2, please use [[Label.shadowUsed]] instead. | ||
*/ | ||
@ccclass('cc.LabelShadow') | ||
@help('i18n:cc.LabelShadow') | ||
|
@@ -60,11 +55,7 @@ export class LabelShadow extends Component { | |
* @zh | ||
* 阴影的颜色。 | ||
* | ||
* @example | ||
* ```ts | ||
* import { Color } from 'cc'; | ||
* labelShadow.color = new Color(0.5, 0.3, 0.7, 1.0); | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.shadowColor]] instead. | ||
*/ | ||
@tooltip('i18n:labelShadow.color') | ||
get color (): Readonly<Color> { | ||
|
@@ -77,7 +68,10 @@ export class LabelShadow extends Component { | |
} | ||
|
||
this._color.set(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No needs to cache color anymore, just set label's property directly |
||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.shadowColor = this._color; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -87,11 +81,7 @@ export class LabelShadow extends Component { | |
* @zh | ||
* 字体与阴影的偏移。 | ||
* | ||
* @example | ||
* ```ts | ||
* import { Vec2 } from 'cc'; | ||
* labelShadow.offset = new Vec2(2, 2); | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.shadowOffset]] instead. | ||
*/ | ||
@tooltip('i18n:labelShadow.offset') | ||
get offset (): Vec2 { | ||
|
@@ -100,7 +90,10 @@ export class LabelShadow extends Component { | |
|
||
set offset (value) { | ||
this._offset = value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No needs to cache color anymore, just set label's property directly |
||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.shadowOffset = this._offset; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -110,10 +103,7 @@ export class LabelShadow extends Component { | |
* @zh | ||
* 阴影的模糊程度。 | ||
* | ||
* @example | ||
* ```ts | ||
* labelShadow.blur = 2; | ||
* ``` | ||
* @deprecated since v3.8.2, please use [[Label.shadowBlur]] instead. | ||
*/ | ||
@tooltip('i18n:labelShadow.blur') | ||
get blur (): number { | ||
|
@@ -122,21 +112,39 @@ export class LabelShadow extends Component { | |
|
||
set blur (value) { | ||
this._blur = value; | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.shadowBlur = this._blur; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.shadowUsed]] instead. | ||
*/ | ||
public onEnable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.shadowUsed = true; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.shadowUsed]] instead. | ||
*/ | ||
public onDisable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.shadowUsed = false; | ||
} | ||
} | ||
|
||
protected _updateRenderData (): void { | ||
/** | ||
* @deprecated since v3.8.2, please use [[Label.outlineUsed]] instead. | ||
*/ | ||
public onLoad (): void { | ||
const label = this.node.getComponent(Label); | ||
if (label) { | ||
label.updateRenderData(true); | ||
if (label && this.enabledInHierarchy) { | ||
label.shadowUsed = true; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs to cache color anymore, just set label's property directly