Selaa lähdekoodia

[fx] Fix crash with not-made subFx animations in fx roots

Clément Espeute 4 kuukautta sitten
vanhempi
commit
c7f45ba28f
2 muutettua tiedostoa jossa 6 lisäystä ja 3 poistoa
  1. 1 1
      hrt/prefab/fx/FX.hx
  2. 5 2
      hrt/prefab/fx/SubFX.hx

+ 1 - 1
hrt/prefab/fx/FX.hx

@@ -384,7 +384,7 @@ class FXAnimation extends h3d.scene.Object {
 	}
 
 	function initEvents(elt: PrefabElement, ?out : Array<Event.EventInstance> ) : Array<Event.EventInstance> {
-		if (elt == null || @:privateAccess !elt.shouldBeInstanciated())
+		if (elt == null || @:privateAccess !elt.shouldBeInstanciated() || elt.findFirstLocal3d() == null)
 			return out;
 
 		if( Std.isOfType(elt, IEvent) ) {

+ 5 - 2
hrt/prefab/fx/SubFX.hx

@@ -34,12 +34,15 @@ class SubFX extends Reference implements hrt.prefab.fx.Event.IEvent{
 
 	public function getDuration() {
 		if (refInstance != null) {
-			var fxAnim : hrt.prefab.fx.FX.FXAnimation = refInstance.findFirstLocal3d().find(o -> Std.downcast(o, hrt.prefab.fx.FX.FXAnimation));
+			var local = refInstance.findFirstLocal3d();
+			if (local == null)
+				return 0.0;
+			var fxAnim : hrt.prefab.fx.FX.FXAnimation = local.find(o -> Std.downcast(o, hrt.prefab.fx.FX.FXAnimation));
 			if (fxAnim != null) {
 				return fxAnim.duration;
 			}
 		}
-		return 0;
+		return 0.0;
 	}
 
 	#if editor