Browse Source

FX: use FXRoot on references in editor

trethaller 4 years ago
parent
commit
f658639182
1 changed files with 5 additions and 8 deletions
  1. 5 8
      hrt/prefab/fx/FX.hx

+ 5 - 8
hrt/prefab/fx/FX.hx

@@ -389,19 +389,17 @@ class FX extends BaseFX {
 		fxanim.duration = duration;
 		fxanim.duration = duration;
 		fxanim.cullingRadius = cullingRadius;
 		fxanim.cullingRadius = cullingRadius;
 		ctx.local3d = fxanim;
 		ctx.local3d = fxanim;
+		var fromRef = ctx.shared.parent != null;
 		#if editor
 		#if editor
 		// only play if we are as a reference
 		// only play if we are as a reference
-		if( ctx.shared.parent != null ) fxanim.playSpeed = 1.0;
+		if( fromRef ) fxanim.playSpeed = 1.0;
 		#else
 		#else
 		fxanim.playSpeed = 1.0;
 		fxanim.playSpeed = 1.0;
 		#end
 		#end
 
 
-		#if editor
-		super.make(ctx);
-		fxanim.init(ctx, this);
-		#else
+		var useFXRoot = #if editor fromRef #else true #end;
 		var root = getFXRoot(ctx, this);
 		var root = getFXRoot(ctx, this);
-		if(root != null){
+		if(useFXRoot && root != null){
 			for( c in root.children ) {
 			for( c in root.children ) {
 				var co = Std.downcast(c , hrt.prefab.l3d.Constraint);
 				var co = Std.downcast(c , hrt.prefab.l3d.Constraint);
 				if( co == null )
 				if( co == null )
@@ -411,8 +409,7 @@ class FX extends BaseFX {
 		else
 		else
 			super.make(ctx);
 			super.make(ctx);
 		fxanim.init(ctx, this, root);
 		fxanim.init(ctx, this, root);
-		#end
-
+		
 		if(scriptCode != null && scriptCode != ""){
 		if(scriptCode != null && scriptCode != ""){
 			var parser = new FXScriptParser();
 			var parser = new FXScriptParser();
 			fxanim.script = parser.createFXScript(scriptCode, fxanim);
 			fxanim.script = parser.createFXScript(scriptCode, fxanim);