ソースを参照

[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 ヶ月 前
コミット
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);