add line updateColor function (#317)

* add line setColor function

* fix eslint

* modify setColor to updateColor
This commit is contained in:
zxx43
2026-08-31 11:56:37 +08:00
committed by GitHub
parent c438c2d3f8
commit 550eb15641
+10 -1
View File
@@ -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);