mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix change 2d custom material bug (#14355)
This commit is contained in:
@@ -193,6 +193,7 @@ export class ParticleSystem2D extends UIRenderer {
|
||||
if (this._custom !== value) {
|
||||
this._custom = value;
|
||||
this._applyFile();
|
||||
this._updateMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1170,13 +1171,11 @@ export class ParticleSystem2D extends UIRenderer {
|
||||
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
|
||||
*/
|
||||
public _updateMaterial () {
|
||||
if (!this._useFile) {
|
||||
if (this._customMaterial) {
|
||||
this.setMaterial(this._customMaterial, 0);
|
||||
const target = this.getRenderMaterial(0)!.passes[0].blendState.targets[0];
|
||||
this._dstBlendFactor = target.blendDst;
|
||||
this._srcBlendFactor = target.blendSrc;
|
||||
}
|
||||
if (this._customMaterial) {
|
||||
this.setMaterial(this._customMaterial, 0);
|
||||
const target = this.getRenderMaterial(0)!.passes[0].blendState.targets[0];
|
||||
this._dstBlendFactor = target.blendDst;
|
||||
this._srcBlendFactor = target.blendSrc;
|
||||
}
|
||||
const mat = this.getMaterialInstance(0);
|
||||
if (mat) mat.recompileShaders({ USE_LOCAL: this._positionType !== PositionType.FREE });
|
||||
|
||||
Reference in New Issue
Block a user