private void DisplayContextButtonsName() { int currentLoaded = _refGameAsset.LastIndexUsed; for (int i = 0; i < _refGameAsset.CountSceneToLoad; i++) { bool currentLoadedScene = currentLoaded == i; bool showFullName = !EditorPrefs.GetBool(UnityEssentialsPreferences.SHOW_INDEX_OF_SCENE, UnityEssentialsPreferences.DEFAULT_SHOW_INDEX_OF_SCENE); string levelIndex = showFullName ? _refGameAsset.GetSceneAtIndex(i).NameContext : (i + 1).ToString(); if (_refGameAsset.GetSceneAtIndex(i) == null) { continue; } GUIContent content = new GUIContent(levelIndex); GUIStyle style = ExtGUIStyles.MicroButton; Vector2 size = style.CalcSize(content); float width = showFullName ? size.x : WIDTH_BUTTON; currentLoadedScene = GUILayout.Toggle(currentLoadedScene, new GUIContent(levelIndex, "Load context[" + levelIndex + "]: " + _refGameAsset.GetSceneAtIndex(i).NameContext), ExtGUIStyles.MicroButton, GUILayout.Width(width), GUILayout.Height(HEIGHT_BUTTON)); if (Event.current.button == 0 && currentLoadedScene != (currentLoaded == i)) { if (!Application.isPlaying) { if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { return; } } _refGameAsset.LastIndexUsed = i; _refGameAsset.LoadScenesByIndex(i, OnLoadedScenes, hardReload: true); EditorGUIUtility.PingObject(_refGameAsset.GetSceneAtIndex(i)); Selection.activeObject = _refGameAsset.GetSceneAtIndex(i); return; } #if UNITY_2018_3_OR_NEWER if (IsRightClickContext()) { CreateGenericMenu(); } #endif } }
public void Load() { _contextLister.LoadScenesByIndex(_index, OnComplete, false); }