File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -44,5 +44,7 @@ private void ApplyAsset(RefPooler pooler)
4444 pooler . MaxSize = maxSize ;
4545 pooler . ReuseObjects = reuseObjects ;
4646 }
47+
48+ public override bool IsContainedIn ( RefResource resource ) => resource == this ;
4749 }
4850}
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ private void OnValidate()
3636 Debug . LogWarning ( "[PoolGroupAsset] Cannot assign itself as pool entry" ) ;
3737 continue ;
3838 }
39+
40+ if ( poolRes . IsContainedIn ( this ) )
41+ {
42+ pools . RemoveAt ( i ) ;
43+ Debug . LogWarning ( "[PoolGroupAsset] Cyclic dependency detected, removing!" ) ;
44+ continue ;
45+ }
3946 }
4047 }
4148
@@ -74,5 +81,18 @@ public override RefComponent CreateComponent()
7481 }
7582 return groupComponent ;
7683 }
84+
85+ public override bool IsContainedIn ( RefResource resource )
86+ {
87+ foreach ( var poolAsset in pools )
88+ {
89+ if ( poolAsset == resource ) return true ;
90+ if ( poolAsset . IsContainedIn ( resource ) )
91+ {
92+ return true ;
93+ }
94+ }
95+ return false ;
96+ }
7797 }
7898}
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ public abstract class RefResource : ScriptableObject
66 {
77 public abstract void Prepare ( ) ;
88 public abstract RefItem Get ( ) ;
9+
10+ public abstract bool IsContainedIn ( RefResource resource ) ;
911 public abstract RefComponent CreateComponent ( ) ;
1012 }
1113}
You can’t perform that action at this time.
0 commit comments