mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 17:42:41 +08:00
fix particle trail material error (#4359)
This commit is contained in:
@@ -360,10 +360,12 @@ export class ParticleSystemComponent extends Component {
|
||||
if (this.playOnAwake) {
|
||||
this.play();
|
||||
}
|
||||
this.renderer!.enabled = this.enabledInHierarchy;
|
||||
this.trailModule.onEnable();
|
||||
}
|
||||
|
||||
protected onDisable () {
|
||||
this.renderer!.enabled = this.enabledInHierarchy;
|
||||
this.trailModule.onDisable();
|
||||
}
|
||||
|
||||
|
||||
@@ -387,7 +387,16 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
}
|
||||
|
||||
public _onMaterialModified (index: number, material: Material) {
|
||||
this._updateMaterialParams();
|
||||
if (index === 0) {
|
||||
this._updateMaterialParams();
|
||||
|
||||
} else {
|
||||
if (this.particleSystem.trailModule.enable) {
|
||||
this.particleSystem.trailModule._updateMaterial();
|
||||
const mat = this.getMaterial(1, CC_EDITOR)!;
|
||||
mat!.recompileShaders(this._trailDefines);
|
||||
}
|
||||
}
|
||||
this._updateModel();
|
||||
}
|
||||
|
||||
@@ -407,7 +416,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
if (this.sharedMaterial == null && this._defaultMat == null) {
|
||||
this._defaultMat = Material.getInstantiatedMaterial(builtinResMgr.get<Material>('default-particle-material'), this, true);
|
||||
}
|
||||
let mat: Material | null = this.sharedMaterial ? this.getMaterial(0, CC_EDITOR)! : this._defaultMat;
|
||||
const mat: Material | null = this.sharedMaterial ? this.getMaterial(0, CC_EDITOR)! : this._defaultMat;
|
||||
if (this.particleSystem._simulationSpace === Space.World) {
|
||||
this._defines[CC_USE_WORLD_SPACE] = true;
|
||||
this._trailDefines[CC_USE_WORLD_SPACE] = true;
|
||||
@@ -458,11 +467,6 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
} else {
|
||||
mat!.setProperty('frameTile_velLenScale', this.frameTile_velLenScale);
|
||||
}
|
||||
|
||||
if (this.particleSystem.trailModule.enable) {
|
||||
mat = this.getMaterial(1, CC_EDITOR)!;
|
||||
mat!.recompileShaders(this._trailDefines);
|
||||
}
|
||||
}
|
||||
|
||||
private _updateModel () {
|
||||
|
||||
Reference in New Issue
Block a user