Editor/LevelsTools.cs
/// <summary>
/// Launches currently selected level from editor
/// </summary>
Launches currently selected level from editor
Launches currently selected level from editor
public static void LaunchLevel(bool ignoreSelection)
        {
            InitializeLevels();
            CollectLevelsInDatabase();
            if (!ignoreSelection)
            {
                var selected = Selection.activeObject;
                if (selected == null)
                {
                    Debug.Log("Select level first.");
                    return;
                }
                Type t = selected.GetType();
                if (t != typeof(Level))
                {
                    Debug.LogError("Select Level!");
                    return;
                }
                selectedLevel = (Level)selected;
            }
            EditorSceneManager.SaveOpenScenes();
            USSEditorPrefs.prefs.StoreSceneSetup(EditorSceneManager.GetSceneManagerSetup());
            int c = EditorSceneManager.loadedSceneCount;
            USSEditorPrefs.prefs.PreviousScenes.Clear();
            for (int i = 0; i < c; i++)
            {
                Scene s = EditorSceneManager.GetSceneAt(0);
                USSEditorPrefs.prefs.PreviousScenes.Add(s.path);
            }
            EditorUtility.SetDirty(USSEditorPrefs.prefs);
            AssetDatabase.SaveAssets();
            if (USSEditorPrefs.prefs.GetLevelLaunchOverrideCallback() == null)
            {
                LaunchDefault(selectedLevel);
            }
            else
            {
                UnityAction<Level> cb = USSEditorPrefs.prefs.GetLevelLaunchOverrideCallback();
                cb(selectedLevel);
            }
        }
public static void LaunchLevel ( bool ignoreSelection ) { InitializeLevels ( ) ; CollectLevelsInDatabase ( ) ; if ( ! ignoreSelection ) { var selected = Selection . activeObject ; if ( selected == null ) { Debug . Log ( " " ) ; return ; } Type t = selected . GetType ( ) ; if ( t != typeof ( Level ) ) { Debug . LogError ( " " ) ; return ; } selectedLevel = ( Level ) selected ; } EditorSceneManager . SaveOpenScenes ( ) ; USSEditorPrefs . prefs . StoreSceneSetup ( EditorSceneManager . GetSceneManagerSetup ( ) ) ; int c = EditorSceneManager . loadedSceneCount ; USSEditorPrefs . prefs . PreviousScenes . Clear ( ) ; for ( int i = 0 ; i < c ; i ++ ) { Scene s = EditorSceneManager . GetSceneAt ( 0 ) ; USSEditorPrefs . prefs . PreviousScenes . Add ( s . path ) ; } EditorUtility . SetDirty ( USSEditorPrefs . prefs ) ; AssetDatabase . SaveAssets ( ) ; if ( USSEditorPrefs . prefs . GetLevelLaunchOverrideCallback ( ) == null ) { LaunchDefault ( selectedLevel ) ; } else { UnityAction < Level > cb = USSEditorPrefs . prefs . GetLevelLaunchOverrideCallback ( ) ; cb ( selectedLevel ) ; } }
Launches currently selected level from editor
Launches currently selected level from editor
//get selection //we save our currently opened scenes setup in our Editor Prefs //clear the scenes we stored last time //now store currently opened ones
ignoreSelection
bool