public static List <SORoomBase> GetAllRooms() { List <SORoomBase> rooms = new List <SORoomBase>(); string[] allRoomBaseFiles = Directory.GetFiles(Application.dataPath, "*.asset", SearchOption.AllDirectories); foreach (string roomFile in allRoomBaseFiles) { string assetPath = "Assets" + roomFile.Replace(Application.dataPath, "").Replace('\\', '/'); SORoomBase source = AssetDatabase.LoadAssetAtPath(assetPath, typeof(SORoomBase)) as SORoomBase; if (source) { rooms.Add(source); } } return(rooms); }
private void DrawRoomBaseButton(SORoomBase roomBase, Color defColor, out bool nowClicked) { nowClicked = false; bool isNowSelectedRoom = (_nowRoomIndex == _selectedRoomIndex); GUIContent roomText = new GUIContent(roomBase.name); Rect roomTextRect = GUILayoutUtility.GetRect(roomText, sceneTextStyle); if (isNowSelectedRoom) { if (focusedWindow == this) { GUI.color = EditorGUIUtility.isProSkin ? proSelectBackground : stdSelectBackground; } else { GUI.color = EditorGUIUtility.isProSkin ? proLostFocusSelectBackground : stdLostFocusSelectBackground; } GUI.DrawTexture(roomTextRect, EditorGUIUtility.whiteTexture); } GUI.color = (EditorGUIUtility.isProSkin ? proTextColor : (isNowSelectedRoom ? stdSelectTextColor : stdTextColor)); GUIStyle nowSceneTextStyle = isNowSelectedRoom ? sceneSelectedTextStyle : sceneTextStyle; nowSceneTextStyle.fontStyle = FontStyle.Bold; GUI.Label(roomTextRect, roomText, nowSceneTextStyle); #region when click Event e = Event.current; if (roomTextRect.Contains(e.mousePosition)) { if (e.type == EventType.MouseDown) { nowClicked = true; _selectedRoomIndex = _nowRoomIndex; } else if (e.type == EventType.MouseUp) { if (e.button == 0) { if (_lastClickedScene == _nowRoomIndex && Time.realtimeSinceStartup - _lastClickTime <= DoubleClickDelay) { var editor = GameObject.Find("LevelEditor").GetComponent <LevelEditor.TilemapEditorScript>(); if (EditorUtility.DisplayDialog("Are you sure?", "Importing this room will overlap the current one without saving it.", "Okay", "Cancel")) { string pathBase = "Assets/ForEditor/"; EnemySpawnPosition enemyPointPrefab = AssetDatabase.LoadAssetAtPath(pathBase + "EnemySpawnPosition.prefab", typeof(EnemySpawnPosition)) as EnemySpawnPosition; PlayerSpawnPosition playerPointPrefab = AssetDatabase.LoadAssetAtPath(pathBase + "PlayerSpawnPosition.prefab", typeof(PlayerSpawnPosition)) as PlayerSpawnPosition; PlatformController movingPlatformPrefab = AssetDatabase.LoadAssetAtPath(pathBase + "MovingPlatform.prefab", typeof(PlatformController)) as PlatformController; Water waterPrefab = AssetDatabase.LoadAssetAtPath(pathBase + "Water/Water.prefab", typeof(Water)) as Water; editor.Import(roomBase, enemyPointPrefab, playerPointPrefab, movingPlatformPrefab, waterPrefab); LevelEditor.TilemapInspectorEditor.RoomNumber = roomBase.roomNumber; } } else { _lastClickedScene = _nowRoomIndex; _lastClickTime = Time.realtimeSinceStartup; } } } } #endregion _nowRoomIndex++; GUI.color = defColor; }