fix change 2d custom material bug (#14355)

This commit is contained in:
zxx43
2023-02-24 13:38:53 +08:00
committed by GitHub
parent 71bb495efc
commit a1dc2d3df5
+6 -7
View File
@@ -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 });