From 550eb15641a718d08d026d1157b2308b2a75859f Mon Sep 17 00:00:00 2001 From: zxx43 Date: Mon, 31 Aug 2026 11:56:37 +0800 Subject: [PATCH] add line updateColor function (#317) * add line setColor function * fix eslint * modify setColor to updateColor --- cocos/particle/line.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cocos/particle/line.ts b/cocos/particle/line.ts index 68b4e2b23a..9d13a519ef 100644 --- a/cocos/particle/line.ts +++ b/cocos/particle/line.ts @@ -25,7 +25,7 @@ import { ccclass, help, executeInEditMode, menu, tooltip, displayOrder, type, serializable, range, visible, override, displayName } from 'cc.decorator'; import { Material, Texture2D } from '../asset/assets'; -import { Vec3, cclegacy, Vec4, Vec2, CCBoolean } from '../core'; +import { Vec3, cclegacy, Vec4, Vec2, CCBoolean, Color } from '../core'; import { LineModel } from './models/line-model'; import { builtinResMgr } from '../asset/asset-manager'; import CurveRange from './animator/curve-range'; @@ -296,6 +296,15 @@ export class Line extends ModelRenderer { } } + public updateColor (): void { + if (this._color) { + if (this._models[0]) { + const lineModel = this._models[0] as LineModel; + lineModel.addLineVertexData(this._positions, this._width, this._color); + } + } + } + protected _onMaterialModified (index: number, material: Material | null): void { super._onMaterialModified(index, material); const matIns = this.getMaterialInstance(0);