-
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
382fff5
Integration of outline and shadow to label
LinYunMo 8a532e8
add test
LinYunMo cc3aae0
change getter/setter
LinYunMo 2ec6076
name change & use assert
LinYunMo 6741339
test name change
LinYunMo ec97648
name change
LinYunMo 33bc9d1
fix
LinYunMo 13d32f3
remove old attribute & add visible
LinYunMo 7aedb0b
remove assert
LinYunMo 7b267d3
fix: gulp-build-h5-source
PPpro 362af9b
Merge pull request #4 from PPpro/PP
LinYunMo 41bf5c7
Revert "fix: gulp-build-h5-source"
LinYunMo 590bb88
Merge pull request #5 from LinYunMo/revert-4-PP
LinYunMo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
|
||
import { ccclass, help, executionOrder, menu, tooltip, requireComponent, executeInEditMode, serializable } from 'cc.decorator'; | ||
import { Component } from '../../scene-graph/component'; | ||
import { Color, cclegacy } from '../../core'; | ||
import { Color, assertIsTrue, cclegacy } from '../../core'; | ||
import { Label } from './label'; | ||
|
||
/** | ||
|
@@ -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.enableOutline]] instead. | ||
*/ | ||
@ccclass('cc.LabelOutline') | ||
@help('i18n:cc.LabelOutline') | ||
|
@@ -64,25 +56,19 @@ 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 | ||
get color (): Readonly<Color> { | ||
return this._color; | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
return label.outlineColor; | ||
} | ||
|
||
set color (value) { | ||
if (this._color === value) { | ||
return; | ||
} | ||
|
||
this._color.set(value); | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
label.outlineColor = value; | ||
} | ||
|
||
/** | ||
|
@@ -92,37 +78,47 @@ 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 { | ||
return this._width; | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
return label.outlineWidth; | ||
} | ||
|
||
set width (value) { | ||
if (this._width === value) { | ||
return; | ||
} | ||
|
||
this._width = value; | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
label.outlineWidth = value; | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.enableOutline]] instead. | ||
*/ | ||
public onEnable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
label.enableOutline = true; | ||
} | ||
|
||
/** | ||
* @deprecated since v3.8.2, please use [[Label.enableOutline]] instead. | ||
*/ | ||
public onDisable (): void { | ||
this._updateRenderData(); | ||
const label = this.node.getComponent(Label); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
label.enableOutline = false; | ||
} | ||
|
||
protected _updateRenderData (): void { | ||
/** | ||
* @deprecated since v3.8.2, please use [[Label.enableOutline]] 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); | ||
assertIsTrue(label, 'Required Label component to work, please add Label component.'); | ||
if (this.enabledInHierarchy) { | ||
label.enableOutline = true; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use
approx
instead!