@@ -43,7 +43,7 @@ public static void ShowWindow()
4343 private SortMode _sortMode = SortMode . ByID ;
4444
4545 private BlockDataEditor _selectedBlock ;
46- private BlockEditorDTO _blockDraft = new BlockEditorDTO ( ) ;
46+ private BlockEditorDto _blockDraft = new BlockEditorDto ( ) ;
4747 private bool _sortAscending = true ;
4848 private Vector2 _scroll ;
4949
@@ -162,7 +162,7 @@ private void DrawExistingBlocks()
162162 if ( _blockLibrary . AllBlocks == null || _blockLibrary . AllBlocks . Count == 0 )
163163 {
164164 SirenixEditorGUI . InfoMessageBox ( "No blocks found." ) ;
165- SirenixEditorGUI . EndBox ( ) ; // не забываем закрыть
165+ SirenixEditorGUI . EndBox ( ) ;
166166 return ;
167167 }
168168
@@ -198,11 +198,26 @@ private void DrawExistingBlocks()
198198 SirenixEditorGUI . EndBoxHeader ( ) ;
199199
200200 GUILayout . BeginHorizontal ( ) ;
201+
202+ GUILayout . Label ( block . Icon != null ? block . Icon . texture : Texture2D . grayTexture ,
203+ GUILayout . Width ( 32 ) , GUILayout . Height ( 32 ) ) ;
201204
202- GUILayout . Label ( block . Icon != null ? block . Icon . texture : Texture2D . grayTexture , GUILayout . Width ( 32 ) ,
203- GUILayout . Height ( 32 ) ) ;
204- GUILayout . FlexibleSpace ( ) ;
205+ GUILayout . Space ( 10 ) ;
206+
207+ if ( block . Prefab != null )
208+ {
209+ GUILayout . Label ( AssetPreview . GetAssetPreview ( block . Prefab ) ?? Texture2D . grayTexture ,
210+ GUILayout . Width ( 32 ) , GUILayout . Height ( 32 ) ) ;
211+ GUILayout . Label ( block . Prefab . name , GUILayout . Width ( 100 ) ) ;
212+ }
213+ else
214+ {
215+ GUILayout . Label ( Texture2D . grayTexture , GUILayout . Width ( 32 ) , GUILayout . Height ( 32 ) ) ;
216+ GUILayout . Label ( "None" , GUILayout . Width ( 100 ) ) ;
217+ }
205218
219+ GUILayout . FlexibleSpace ( ) ;
220+
206221 if ( GUILayout . Button ( "Select" , GUILayout . Width ( 60 ) ) )
207222 {
208223 _selectedBlock = block ;
@@ -211,8 +226,7 @@ private void DrawExistingBlocks()
211226
212227 if ( GUILayout . Button ( "X" , GUILayout . Width ( 20 ) ) )
213228 {
214- if ( EditorUtility . DisplayDialog ( "Delete Block" , $ "Are you sure you want to delete '{ block . ID } '?",
215- "Yes" , "No" ) )
229+ if ( EditorUtility . DisplayDialog ( "Delete Block" , $ "Are you sure you want to delete '{ block . ID } '?", "Yes" , "No" ) )
216230 {
217231 var path = AssetDatabase . GetAssetPath ( block ) ;
218232 _blockLibrary . AllBlocks . Remove ( block ) ;
@@ -272,28 +286,4 @@ private int SafeCompare(UnityEngine.Object a, UnityEngine.Object b)
272286 }
273287 }
274288 }
275-
276- [ Serializable ]
277- public class BlockEditorDTO
278- {
279- public string Id ;
280- public Sprite Icon ;
281- public GameObject Prefab ;
282-
283- public void LoadFrom ( BlockDataEditor block )
284- {
285- Id = block . ID ;
286- Icon = block . Icon ;
287- Prefab = block . Prefab ;
288- }
289-
290- public void ApplyTo ( BlockDataEditor block )
291- {
292- block . SetID ( Id ) ;
293- block . SetIcon ( Icon ) ;
294- block . SetPrefab ( Prefab ) ;
295- EditorUtility . SetDirty ( block ) ;
296- AssetDatabase . SaveAssets ( ) ;
297- }
298- }
299289}
0 commit comments