File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
186186
187187### [ Unreleased]
188188- Added automatically open of the selected collectable when using the goto button on the CollectableProperty Drawer
189+ - Added type specific GetEnumerator for the Collection
189190
190191
191192[ 1.3.2 ] : https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.3.2
Original file line number Diff line number Diff line change @@ -7,28 +7,16 @@ namespace BrunoMikoski.ScriptableObjectCollections
77{
88 public static class TypeUtility
99 {
10- private static List < Type > cachedAvaliableTypes ;
10+ private static List < Type > cachedAvailableTypes ;
1111
12- private static List < Type > AvailableTypes
13- {
14- get
15- {
16- if ( cachedAvaliableTypes != null )
17- return cachedAvaliableTypes ;
18-
19- cachedAvaliableTypes = new List < Type > ( ) ;
20- Assembly [ ] assemblies = AppDomain . CurrentDomain . GetAssemblies ( ) ;
21- for ( int i = 0 ; i < assemblies . Length ; i ++ )
22- {
23- Assembly assembly = assemblies [ i ] ;
24- if ( assembly == null )
25- continue ;
26-
27- cachedAvaliableTypes . AddRange ( assembly . GetTypes ( ) ) ;
28- }
12+ private static List < Type > AvailableTypes => cachedAvailableTypes ?? ( cachedAvailableTypes = GetTypesFromAssemblies ( ) ) ;
2913
30- return cachedAvaliableTypes ;
31- }
14+ private static List < Type > GetTypesFromAssemblies ( )
15+ {
16+ return AppDomain . CurrentDomain . GetAssemblies ( )
17+ . Where ( x => x != null )
18+ . SelectMany ( x => x . GetTypes ( ) )
19+ . ToList ( ) ;
3220 }
3321
3422 private static Dictionary < Type , List < Type > > typeToSubclasses = new Dictionary < Type , List < Type > > ( ) ;
Original file line number Diff line number Diff line change @@ -401,6 +401,22 @@ public static ScriptableObjectCollection<ObjectType> Values
401401 set => base [ index ] = value ;
402402 }
403403
404+ public IEnumerator < ObjectType > GetEnumerator ( )
405+ {
406+ using ( IEnumerator < CollectableScriptableObject > itemEnum = base . GetEnumerator ( ) )
407+ {
408+ while ( itemEnum . MoveNext ( ) )
409+ {
410+ if ( itemEnum . Current . IsNull ( ) )
411+ continue ;
412+ ObjectType obj = itemEnum . Current as ObjectType ;
413+ if ( obj == null )
414+ continue ;
415+ yield return obj ;
416+ }
417+ }
418+ }
419+
404420#if UNITY_EDITOR
405421
406422 public T GetOrAddNew < T > ( string targetName = null ) where T : ObjectType
You can’t perform that action at this time.
0 commit comments