Parcourir la source

[ref] Fix editor load of invalid refs

Clément Espeute il y a 4 mois
Parent
commit
6c4f0f42fe
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      hrt/prefab/Reference.hx

+ 7 - 1
hrt/prefab/Reference.hx

@@ -91,7 +91,11 @@ class Reference extends Object3D {
 		var otherRef : Reference = cast obj;
 
 		#if editor
-		originalSource = @:privateAccess hxd.res.Loader.currentInstance.load(source).toPrefab().loadData();
+		try {
+			originalSource = @:privateAccess hxd.res.Loader.currentInstance.load(source).toPrefab().loadData();
+		} catch (e) {
+
+		}
 		#end
 
 		// Clone the refInstance from the original prefab on copy
@@ -168,6 +172,8 @@ class Reference extends Object3D {
 		// in the case source has changed since the last load (can happen when creating references manually)
 		if (refInstance?.shared.currentPath != source) {
 			initRefInstance();
+			if (refInstance == null)
+				return;
 			refInstance = refInstance.clone();
 		}
 		#if editor