Browse Source

[fx] Fix emitter parameters being reset when emitter was re-init in editor

Clément Espeute 8 months ago
parent
commit
25129054a5
2 changed files with 11 additions and 3 deletions
  1. 11 0
      hrt/prefab/fx/Emitter.hx
  2. 0 3
      hrt/prefab/fx/FX.hx

+ 11 - 0
hrt/prefab/fx/Emitter.hx

@@ -746,6 +746,17 @@ class EmitterObject extends h3d.scene.Object {
 		randomValues = [for(i in 0...(maxCount * randSlots)) 0];
 		evaluator = new Evaluator(randomValues, randSlots);
 
+		{
+			var p = parent;
+			while (p != null && Std.downcast(p, hrt.prefab.fx.FX.FXAnimation) == null) {
+				p = p.parent;
+			}
+			if (p != null) {
+				var fx : hrt.prefab.fx.FX.FXAnimation = cast p;
+				@:privateAccess evaluator.parameters = fx.evaluator.parameters;
+			}
+		}
+
 		reset();
 	}
 

+ 0 - 3
hrt/prefab/fx/FX.hx

@@ -63,9 +63,6 @@ class FXAnimation extends h3d.scene.Object {
 			}
 		}
 
-		for (emitter in this.findAll((f) -> Std.downcast(f, hrt.prefab.fx.Emitter.EmitterObject))) {
-			@:privateAccess emitter.evaluator.parameters = evaluator.parameters;
-		}
 
 		events = initEvents(root, events);
 		var root = hrt.prefab.fx.BaseFX.BaseFXTools.getFXRoot(def);