77 * Copyright (c) 2016 by Shen, Jen-Chieh $
88 */
99using System . Collections . Generic ;
10+ using System . Linq ;
1011using UnityEngine ;
1112using MyBox ;
1213
@@ -21,7 +22,7 @@ public class JCS_UIManager : JCS_Manager<JCS_UIManager>
2122
2223#if UNITY_EDITOR
2324 [ Separator ( "Helper Variables (JCS_UIManager)" ) ]
24-
25+
2526 [ Tooltip ( "Test this component with key?" ) ]
2627 [ SerializeField ]
2728 private bool mTestWithKey = false ;
@@ -176,31 +177,16 @@ private void Test()
176177 public void AddCanvas ( JCS_Canvas canvas )
177178 {
178179 mCanvases . Add ( canvas ) ;
179- mCanvases = JCS_Array . RemoveEmptyMissing ( mCanvases ) ;
180- mCanvases = SortCanvases_Insertion ( ) ;
181- }
182- private List < JCS_Canvas > SortCanvases_Insertion ( )
183- {
184- for ( int i = 0 ; i < mCanvases . Count ; ++ i )
185- {
186- for ( int j = i ; j > 0 ; -- j )
187- {
188- if ( mCanvases [ j ] . canvas . sortingOrder < mCanvases [ j - 1 ] . canvas . sortingOrder )
189- {
190- JCS_Canvas temp = mCanvases [ j ] ;
191- mCanvases [ j ] = mCanvases [ j - 1 ] ;
192- mCanvases [ j - 1 ] = temp ;
193- }
194- }
195- }
196- return mCanvases ;
180+ mCanvases = mCanvases . OrderBy ( x => x . canvas . sortingOrder ) . ToList ( ) ;
197181 }
198182
199183 /// <summary>
200184 /// Return the canvas by name.
201185 /// </summary>
202186 public JCS_Canvas CanvasByName ( string name )
203187 {
188+ mCanvases = JCS_Array . RemoveEmptyMissing ( mCanvases ) ;
189+
204190 foreach ( JCS_Canvas canvas in mCanvases )
205191 {
206192 if ( canvas . name == name )
@@ -219,10 +205,10 @@ public void HideTheLastOpenDialogue()
219205 if ( GetOpenWindow ( ) . Count == 0 )
220206 return ;
221207
222- JCS_DialogueObject jdo = GetOpenWindow ( ) . Last . Value ;
208+ JCS_DialogueObject dialogue = GetOpenWindow ( ) . Last . Value ;
223209
224210 // once it hide it will remove from the list it self!
225- jdo . Hide ( ) ;
211+ dialogue . Hide ( ) ;
226212 }
227213
228214 /// <summary>
0 commit comments