@@ -12,13 +12,14 @@ private static void GitFileHistory()
1212 {
1313 if ( Selection . assetGUIDs != null )
1414 {
15- var assetPath = AssetDatabase . GUIDToAssetPath ( Selection . assetGUIDs . First ( ) )
16- . ToNPath ( ) ;
15+ var assetPath =
16+ AssetDatabase . GUIDToAssetPath ( Selection . assetGUIDs . First ( ) )
17+ . ToNPath ( ) ;
1718
1819 var windowType = typeof ( Window ) ;
1920 var fileHistoryWindow = GetWindow < FileHistoryWindow > ( windowType ) ;
2021 fileHistoryWindow . InitializeWindow ( EntryPoint . ApplicationManager ) ;
21- fileHistoryWindow . Open ( assetPath ) ;
22+ fileHistoryWindow . SetSelectedPath ( assetPath ) ;
2223 fileHistoryWindow . Show ( ) ;
2324 }
2425 }
@@ -32,13 +33,31 @@ private static bool GitFileHistoryValidation()
3233 private const string Title = "File History" ;
3334
3435 [ NonSerialized ] private bool firstOnGUI = true ;
36+ [ NonSerialized ] private Texture selectedIcon ;
3537
36- [ SerializeField ] private bool locked ;
38+ [ SerializeField ] private bool locked = true ;
3739 [ SerializeField ] private FileHistoryView fileHistoryView = new FileHistoryView ( ) ;
40+ [ SerializeField ] private NPath selectedAssetPath ;
3841
39- public void Open ( NPath path )
42+ public void SetSelectedPath ( NPath path )
4043 {
41- Repository . UpdateFileLog ( path )
44+ selectedAssetPath = path ;
45+
46+ Texture nodeIcon = null ;
47+
48+ if ( selectedAssetPath != NPath . Default )
49+ {
50+ nodeIcon = UnityEditorInternal . InternalEditorUtility . GetIconForFile ( selectedAssetPath . ToString ( ) ) ;
51+ }
52+
53+ if ( nodeIcon != null )
54+ {
55+ nodeIcon . hideFlags = HideFlags . HideAndDontSave ;
56+ }
57+
58+ selectedIcon = nodeIcon ;
59+
60+ Repository . UpdateFileLog ( selectedAssetPath )
4261 . Start ( ) ;
4362 }
4463
@@ -78,12 +97,6 @@ public override void OnDataUpdate()
7897 fileHistoryView . OnDataUpdate ( ) ;
7998 }
8099
81- public override void OnFocusChanged ( )
82- {
83- if ( fileHistoryView != null )
84- fileHistoryView . OnFocusChanged ( ) ;
85- }
86-
87100 public override void OnRepositoryChanged ( IRepository oldRepository )
88101 {
89102 base . OnRepositoryChanged ( oldRepository ) ;
@@ -106,14 +119,28 @@ public override void OnSelectionChange()
106119 base . OnSelectionChange ( ) ;
107120 if ( fileHistoryView != null )
108121 fileHistoryView . OnSelectionChange ( ) ;
122+
123+ if ( ! locked )
124+ {
125+ var assetGuid = Selection . assetGUIDs . FirstOrDefault ( ) ;
126+
127+ selectedAssetPath = NPath . Default ;
128+ if ( assetGuid != null )
129+ {
130+ selectedAssetPath = AssetDatabase . GUIDToAssetPath ( assetGuid )
131+ . ToNPath ( ) ;
132+ }
133+
134+ SetSelectedPath ( selectedAssetPath ) ;
135+ }
109136 }
110137
111138 public override void Refresh ( )
112139 {
113140 base . Refresh ( ) ;
114141 if ( fileHistoryView != null )
115142 fileHistoryView . Refresh ( ) ;
116- Refresh ( CacheType . GitLocks ) ;
143+ Refresh ( CacheType . GitFileLog ) ;
117144 Redraw ( ) ;
118145 }
119146
@@ -123,6 +150,8 @@ public override void OnUI()
123150
124151 GUILayout . BeginVertical ( Styles . HeaderStyle ) ;
125152 {
153+ DoHeaderGUI ( ) ;
154+
126155 fileHistoryView . OnGUI ( ) ;
127156 }
128157 GUILayout . EndVertical ( ) ;
@@ -160,5 +189,25 @@ private void ShowButton(Rect rect)
160189
161190 this . OnSelectionChange ( ) ;
162191 }
192+
193+ private void DoHeaderGUI ( )
194+ {
195+ GUILayout . BeginHorizontal ( Styles . HeaderBoxStyle ) ;
196+ {
197+ GUILayout . BeginVertical ( ) ;
198+ {
199+ GUILayout . Space ( 3 ) ;
200+
201+ var iconWidth = 32 ;
202+ var iconHeight = 32 ;
203+
204+ GUILayout . Label ( selectedIcon , GUILayout . Height ( iconWidth ) , GUILayout . Width ( iconHeight ) ) ;
205+
206+ GUILayout . Label ( selectedAssetPath , Styles . Label ) ;
207+ }
208+ GUILayout . EndVertical ( ) ;
209+ }
210+ GUILayout . EndHorizontal ( ) ;
211+ }
163212 }
164213}
0 commit comments