File tree Expand file tree Collapse file tree 3 files changed +41
-3944
lines changed
Resources/StaticData/LevelsData Expand file tree Collapse file tree 3 files changed +41
-3944
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,47 @@ private void CreateNewLevelEditor()
9292 SelectedName = NewLevelName ;
9393 }
9494
95+ [ BoxGroup ( "Select Level" ) ]
96+ [ GUIColor ( 1f , 0.4f , 0.4f ) ]
97+ [ ShowIf ( nameof ( SelectedLevelEditor ) ) ]
98+ [ Button ( "🗑 Delete Selected Level" , ButtonSizes . Large ) ]
99+ private void DeleteSelectedLevelEditor ( )
100+ {
101+ if ( SelectedLevelEditor == null )
102+ {
103+ Debug . LogWarning ( "⚠️ No level selected to delete." ) ;
104+ return ;
105+ }
106+
107+ if ( EditorUtility . DisplayDialog (
108+ "Delete Level" ,
109+ $ "Are you sure you want to delete '{ SelectedLevelEditor . name } '?\n This cannot be undone.",
110+ "Delete" , "Cancel" ) )
111+ {
112+ string path = AssetDatabase . GetAssetPath ( SelectedLevelEditor ) ;
113+
114+ SelectedLevelEditor = null ;
115+ SelectedName = string . Empty ;
116+
117+ if ( ! string . IsNullOrEmpty ( path ) )
118+ {
119+ AssetDatabase . DeleteAsset ( path ) ;
120+ AssetDatabase . SaveAssets ( ) ;
121+ AssetDatabase . Refresh ( ) ;
122+
123+ Debug . Log ( $ "🗑 Deleted level: { path } ") ;
124+ }
125+
126+ LoadLevelEditors ( ) ;
127+
128+ if ( levelEditors . Count > 0 )
129+ {
130+ SelectedLevelEditor = levelEditors [ 0 ] ;
131+ SelectedName = SelectedLevelEditor . name ;
132+ }
133+ }
134+ }
135+
95136 private void OnEnable ( )
96137 {
97138 LoadLevelEditors ( ) ;
You can’t perform that action at this time.
0 commit comments