@@ -20,6 +20,7 @@ public sealed class DataToolkitWindow : EditorWindow
2020 private const float HeaderBodySpacing = 4f ;
2121 private const float SplitterWidth = 5f ;
2222 private const float RowHeight = 24f ;
23+ private const long LargeAssetInspectorThresholdBytes = 512 * 1024 ;
2324
2425 private readonly CompositeAssetInspector inspector = new ( ) ;
2526 private readonly Dictionary < Type , int > assetCountCache = new ( ) ;
@@ -40,6 +41,7 @@ public sealed class DataToolkitWindow : EditorWindow
4041 private float assetColumnWidth = DefaultAssetColumnWidth ;
4142 private string activeResizeKey ;
4243 private bool isWarmingAssetCounts ;
44+ private bool allowFullInspectorForSelectedAsset ;
4345
4446 private readonly struct SelectionSnapshot
4547 {
@@ -342,17 +344,24 @@ private void DrawSelectedAssetInspector(Rect rect)
342344
343345 EditorGUILayout . EndHorizontal ( ) ;
344346
345- inspector . SetTarget ( selectedAsset ) ;
346- inspectorScroll = EditorGUILayout . BeginScrollView ( inspectorScroll ) ;
347- EditorGUI . BeginChangeCheck ( ) ;
348- inspector . Draw ( ) ;
349- if ( EditorGUI . EndChangeCheck ( ) )
347+ if ( ShouldDeferFullInspector ( selectedAsset ) && ! allowFullInspectorForSelectedAsset )
350348 {
351- EditorUtility . SetDirty ( selectedAsset ) ;
352- Repaint ( ) ;
349+ DrawDeferredInspectorState ( ) ;
350+ }
351+ else
352+ {
353+ inspector . SetTarget ( selectedAsset ) ;
354+ inspectorScroll = EditorGUILayout . BeginScrollView ( inspectorScroll ) ;
355+ EditorGUI . BeginChangeCheck ( ) ;
356+ inspector . Draw ( ) ;
357+ if ( EditorGUI . EndChangeCheck ( ) )
358+ {
359+ EditorUtility . SetDirty ( selectedAsset ) ;
360+ Repaint ( ) ;
361+ }
362+
363+ EditorGUILayout . EndScrollView ( ) ;
353364 }
354-
355- EditorGUILayout . EndScrollView ( ) ;
356365 }
357366 }
358367 GUILayout . EndArea ( ) ;
@@ -363,6 +372,79 @@ private void DrawEmptyInspectorState()
363372 EditorGUILayout . HelpBox ( "Select a data asset from the middle column." , MessageType . Info ) ;
364373 }
365374
375+ private void DrawDeferredInspectorState ( )
376+ {
377+ var assetPath = ResolveSelectedAssetPath ( ) ;
378+ var sizeInBytes = GetAssetFileSize ( assetPath ) ;
379+
380+ EditorGUILayout . HelpBox (
381+ "This asset is large, so the full inspector is deferred to keep Data Manager responsive." ,
382+ MessageType . Info ) ;
383+
384+ EditorGUILayout . LabelField ( "Type" , selectedAsset . GetType ( ) . Name ) ;
385+ EditorGUILayout . LabelField ( "Path" , string . IsNullOrEmpty ( assetPath ) ? "(unknown)" : assetPath ) ;
386+ EditorGUILayout . LabelField ( "Size" , FormatByteSize ( sizeInBytes ) ) ;
387+
388+ EditorGUILayout . Space ( 8f ) ;
389+ if ( GUILayout . Button ( "Open Full Inspector" , GUILayout . Height ( 28f ) ) )
390+ {
391+ allowFullInspectorForSelectedAsset = true ;
392+ inspector . SetTarget ( selectedAsset ) ;
393+ Repaint ( ) ;
394+ }
395+ }
396+
397+ private bool ShouldDeferFullInspector ( UnityEngine . Object asset )
398+ {
399+ if ( asset == null )
400+ {
401+ return false ;
402+ }
403+
404+ var assetPath = ResolveSelectedAssetPath ( ) ;
405+ return GetAssetFileSize ( assetPath ) > LargeAssetInspectorThresholdBytes ;
406+ }
407+
408+ private string ResolveSelectedAssetPath ( )
409+ {
410+ if ( ! string . IsNullOrEmpty ( selectedAssetPath ) )
411+ {
412+ return selectedAssetPath ;
413+ }
414+
415+ return selectedAsset == null ? null : AssetDatabase . GetAssetPath ( selectedAsset ) ;
416+ }
417+
418+ private static long GetAssetFileSize ( string assetPath )
419+ {
420+ if ( string . IsNullOrEmpty ( assetPath ) )
421+ {
422+ return 0L ;
423+ }
424+
425+ if ( ! File . Exists ( assetPath ) )
426+ {
427+ return 0L ;
428+ }
429+
430+ return new FileInfo ( assetPath ) . Length ;
431+ }
432+
433+ private static string FormatByteSize ( long bytes )
434+ {
435+ if ( bytes <= 0L )
436+ {
437+ return "0 KB" ;
438+ }
439+
440+ if ( bytes < 1024L * 1024L )
441+ {
442+ return $ "{ Mathf . CeilToInt ( bytes / 1024f ) } KB";
443+ }
444+
445+ return $ "{ bytes / ( 1024f * 1024f ) : 0.0} MB";
446+ }
447+
366448 private bool DrawSelectableRow ( string title , string countText , bool selected )
367449 {
368450 var rect = GUILayoutUtility . GetRect ( 1f , RowHeight , GUILayout . ExpandWidth ( true ) ) ;
@@ -483,7 +565,8 @@ private void SelectAsset(UnityEngine.Object asset)
483565 selectedAsset = asset ;
484566 Selection . activeObject = asset ;
485567 inspectorScroll = Vector2 . zero ;
486- inspector . SetTarget ( asset ) ;
568+ allowFullInspectorForSelectedAsset = false ;
569+ inspector . SetTarget ( null ) ;
487570 }
488571
489572 private void ClearSelectedAsset ( )
@@ -492,6 +575,7 @@ private void ClearSelectedAsset()
492575 selectedAsset = null ;
493576 Selection . activeObject = null ;
494577 inspectorScroll = Vector2 . zero ;
578+ allowFullInspectorForSelectedAsset = false ;
495579 inspector . SetTarget ( null ) ;
496580 }
497581
0 commit comments