将 UIRenderer 的 _fillColorType 属性 改为 protected #18914
Open
finscn wants to merge 3 commits into
Open
Conversation
Code Size Check Report
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -1410,8 +1410,13 @@
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
*/
get renderEntity(): __private._cocos_2d_renderer_render_entity__RenderEntity;
/**
+ * @en UI rendering component fill color type, COLOR means using color property value to fill, VERTEX means using vertex color value to fill.
+ * @zh UI 渲染组件填充颜色类型,COLOR 表示使用 color 属性值填充,VERTEX 表示使用顶点颜色值填充。
+ */
+ protected _fillColorType: __private._cocos_2d_renderer_render_entity__RenderEntityFillColorType;
+ /**
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
*/
protected set _useVertexOpacity(val: boolean);
/**
@@ -46423,9 +46428,9 @@
* @zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。
*/
export class MotionStreak extends UIRenderer {
static Point: typeof __private._cocos_particle_2d_motion_streak_2d__Point;
- constructor();
+ protected _fillColorType: __private._cocos_2d_renderer_render_entity__RenderEntityFillColorType;
/**
* @en Preview the trailing effect in editor mode.
* @zh 在编辑器模式下预览拖尾效果。
*/
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
修改理由:
Greptile Summary
Changed
UIRenderer._fillColorTypefrom private to protected with explicit type annotation, allowing subclasses to override the default value directly through property initialization instead of requiring a constructor.MotionStreakby removing its constructor and directly setting_fillColorType = RenderEntityFillColorType.VERTEX_renderEntity.setFillColorType(this._fillColorType)call inUIRenderer.onLoad()to ensure the render entity is properly configured with the (potentially overridden) fill color type: RenderEntityFillColorTypeto_fillColorTypeproperty for better type safetyConfidence Score: 5/5
setFillColorType()inonLoad()ensures proper initialization. The refactoring ofMotionStreakdemonstrates the benefit of this change by eliminating boilerplate constructor code. This is a clean refactoring with no functional changes to existing behavior.Important Files Changed
_fillColorTypefrom private to protected with explicit type annotation, added initialization call inonLoad()_fillColorTypeas a protected property with VERTEX valueSequence Diagram
sequenceDiagram participant Subclass as MotionStreak (Subclass) participant Base as UIRenderer (Base) participant Entity as RenderEntity Note over Subclass,Entity: Before PR: Constructor approach Subclass->>Base: constructor() Base->>Base: _fillColorType = COLOR (default) Base->>Entity: createRenderEntity() Subclass->>Base: setFillColorType(VERTEX) Base->>Base: _fillColorType = VERTEX Base->>Entity: setFillColorType(VERTEX) Note over Subclass,Entity: After PR: Property override approach Subclass->>Subclass: _fillColorType = VERTEX (property initialization) Subclass->>Base: constructor() Base->>Base: (skips _fillColorType init, already set) Base->>Entity: createRenderEntity() Note over Base: onLoad() lifecycle Base->>Entity: setFillColorType(_fillColorType) Entity->>Entity: Applies VERTEX value