Просмотр исходного кода

[prefab] Don't follow ref in findAll if the ref is not shouldBeInstanciated

This avoid an edge cas where the ref wouldn't be followed if the reference was never made (because refInstance would be null) but would be followed if it was made, then disabled (like in the editor with the enabled flag)
Clément Espeute 6 месяцев назад
Родитель
Сommit
3eadcc7ade
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      hrt/prefab/Prefab.hx

+ 2 - 2
hrt/prefab/Prefab.hx

@@ -461,14 +461,14 @@ class Prefab {
 		The result is stored in the given array `arr` if it's defined, otherwise an array is created. The final array
 		is then returned.
 	**/
-	public function findAll<T:Prefab>(?cl: Class<T>, ?filter : Prefab -> Bool, followRefs : Bool = false, ?arr : Array<T> ) : Array<T> {
+	public function findAll<T:Prefab>(?cl: Class<T>, ?filter : T -> Bool, followRefs : Bool = false, ?arr : Array<T> ) : Array<T> {
 		if( arr == null ) arr = [];
 		var asCl = cl != null ? Std.downcast(this, cl) : cast this;
 		if (asCl != null) {
 			if (filter == null || filter(asCl))
 				arr.push(asCl);
 		}
-		if (followRefs) {
+		if (followRefs && this.shouldBeInstanciated()) {
 			var ref = to(Reference);
 			if (ref != null && ref.refInstance != null) {
 				ref.refInstance.findAll(cl, filter, followRefs, arr);