浏览代码

[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
 		The result is stored in the given array `arr` if it's defined, otherwise an array is created. The final array
 		is then returned.
 		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 = [];
 		if( arr == null ) arr = [];
 		var asCl = cl != null ? Std.downcast(this, cl) : cast this;
 		var asCl = cl != null ? Std.downcast(this, cl) : cast this;
 		if (asCl != null) {
 		if (asCl != null) {
 			if (filter == null || filter(asCl))
 			if (filter == null || filter(asCl))
 				arr.push(asCl);
 				arr.push(asCl);
 		}
 		}
-		if (followRefs) {
+		if (followRefs && this.shouldBeInstanciated()) {
 			var ref = to(Reference);
 			var ref = to(Reference);
 			if (ref != null && ref.refInstance != null) {
 			if (ref != null && ref.refInstance != null) {
 				ref.refInstance.findAll(cl, filter, followRefs, arr);
 				ref.refInstance.findAll(cl, filter, followRefs, arr);