From 1e5248286adf48a214b3d503f3e7768eca77592b Mon Sep 17 00:00:00 2001 From: zxg0622 <247274249@qq.com> Date: Sun, 29 Sep 2019 15:36:25 +0800 Subject: [PATCH] sync emitfrom based on shapetype (#5487) --- cocos/particle/emitter/shape-module.ts | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cocos/particle/emitter/shape-module.ts b/cocos/particle/emitter/shape-module.ts index 6c4647a02e..a81917097b 100644 --- a/cocos/particle/emitter/shape-module.ts +++ b/cocos/particle/emitter/shape-module.ts @@ -104,8 +104,38 @@ export default class ShapeModule { @property({ type: ShapeType, displayOrder: 1, + formerlySerializedAs: 'shapeType', }) - public shapeType = ShapeType.Cone; + public _shapeType = ShapeType.Cone; + + @property({ + type: ShapeType, + }) + public get shapeType () { + return this._shapeType; + } + + public set shapeType (val) { + this._shapeType = val; + switch (this._shapeType) { + case ShapeType.Box: + if (this.emitFrom === EmitLocation.Base) { + this.emitFrom = EmitLocation.Volume; + } + break; + case ShapeType.Cone: + if (this.emitFrom === EmitLocation.Edge) { + this.emitFrom = EmitLocation.Base; + } + break; + case ShapeType.Sphere: + case ShapeType.Hemisphere: + if (this.emitFrom === EmitLocation.Base || this.emitFrom === EmitLocation.Edge) { + this.emitFrom = EmitLocation.Volume; + } + break; + } + } /** * @zh 粒子从发射器哪个部位发射 [[EmitLocation]]。