浏览代码

don't set fields that don't exists (keep default values)

ncannasse 8 年之前
父节点
当前提交
8d2366ad7c
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 2 1
      h2d/Particles.hx
  2. 2 1
      h3d/parts/GpuParticles.hx

+ 2 - 1
h2d/Particles.hx

@@ -317,7 +317,8 @@ class ParticleGroup {
 
 	public function load( version : Int, o : Dynamic ) {
 		for( f in getFields(this) )
-			Reflect.setProperty(this, f, Reflect.field(o, f));
+			if( Reflect.hasField(o,f) )
+				Reflect.setProperty(this, f, Reflect.field(o, f));
 		emitMode = PartEmitMode.createByName(o.emitMode);
 		sortMode = PartSortMode.createByName(o.sortMode);
 		blendMode = BlendMode.createByName(o.blendMode);

+ 2 - 1
h3d/parts/GpuParticles.hx

@@ -231,7 +231,8 @@ class GpuPartGroup {
 
 	public function load( version : Int, o : Dynamic ) {
 		for( f in getFields(this) )
-			Reflect.setField(this, f, Reflect.field(o, f));
+			if( Reflect.hasField(o,f) )
+				Reflect.setField(this, f, Reflect.field(o, f));
 		sortMode = GpuSortMode.createByIndex(o.sortMode);
 		emitMode = GpuEmitMode.createByIndex(o.emitMode);
 		texture = loadTexture(o.texture);