Skip to content

Commit f31bdb4

Browse files
committed
add line setColor function
1 parent f5eaf97 commit f31bdb4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cocos/particle/line.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import { ccclass, help, executeInEditMode, menu, tooltip, displayOrder, type, serializable,
2626
range, visible, override, displayName } from 'cc.decorator';
2727
import { Material, Texture2D } from '../asset/assets';
28-
import { Vec3, cclegacy, Vec4, Vec2, CCBoolean } from '../core';
28+
import { Vec3, cclegacy, Vec4, Vec2, CCBoolean, Color } from '../core';
2929
import { LineModel } from './models/line-model';
3030
import { builtinResMgr } from '../asset/asset-manager';
3131
import CurveRange from './animator/curve-range';
@@ -296,6 +296,16 @@ export class Line extends ModelRenderer {
296296
}
297297
}
298298

299+
public setColor(color: Color): void {
300+
if (this._color) {
301+
this._color.color.set(color);
302+
if (this._models[0]) {
303+
const lineModel = this._models[0] as LineModel;
304+
lineModel.addLineVertexData(this._positions, this._width, this._color);
305+
}
306+
}
307+
}
308+
299309
protected _onMaterialModified (index: number, material: Material | null): void {
300310
super._onMaterialModified(index, material);
301311
const matIns = this.getMaterialInstance(0);

0 commit comments

Comments
 (0)