File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public ScriptableObjectCollection GetCollectionByGUID(string guid)
9898 return null ;
9999 }
100100
101- public bool TryGetCollection < T > ( out T resultCollection ) where T : ScriptableObjectCollection
101+ public bool TryGetCollectionOfType < T > ( out T resultCollection ) where T : ScriptableObjectCollection
102102 {
103103 for ( int i = 0 ; i < collections . Count ; i ++ )
104104 {
Original file line number Diff line number Diff line change @@ -401,6 +401,18 @@ public static ScriptableObjectCollection<ObjectType> Values
401401 }
402402
403403#if UNITY_EDITOR
404+
405+ public T GetOrAddNew < T > ( string targetName = null ) where T : ObjectType
406+ {
407+ if ( ! string . IsNullOrEmpty ( targetName ) )
408+ {
409+ T item = Items . FirstOrDefault ( o => o . name . Equals ( targetName , StringComparison . Ordinal ) ) as T ;
410+ if ( item != null )
411+ return item ;
412+ }
413+
414+ return ( T ) AddNew ( typeof ( T ) , targetName ) ;
415+ }
404416
405417 public ObjectType GetOrAddNew ( Type collectionType , string targetName )
406418 {
@@ -424,12 +436,12 @@ public ObjectType AddNew(string targetName)
424436 {
425437 return ( ObjectType ) AddNew ( GetCollectionType ( ) , targetName ) ;
426438 }
427- #endif
428439
429440 public ObjectType AddNew ( )
430441 {
431442 return ( ObjectType ) AddNew ( GetCollectionType ( ) ) ;
432443 }
444+ #endif
433445
434446 public ObjectType GetCollectableByGUID ( string targetGUID )
435447 {
You can’t perform that action at this time.
0 commit comments