@@ -37,34 +37,35 @@ private static bool GitFileHistoryValidation()
3737
3838 [ SerializeField ] private bool locked ;
3939 [ SerializeField ] private FileHistoryView fileHistoryView = new FileHistoryView ( ) ;
40- [ SerializeField ] private NPath selectedAssetPath ;
40+ [ SerializeField ] private UnityEngine . Object selectedObject ;
41+ [ SerializeField ] private NPath selectedObjectPath ;
4142
4243 public void SetSelectedPath ( NPath path )
4344 {
44- selectedAssetPath = path ;
45+ selectedObjectPath = path ;
46+ selectedObject = null ;
4547
4648 Texture nodeIcon = null ;
4749
48- if ( selectedAssetPath != NPath . Default )
50+ if ( selectedObjectPath != NPath . Default )
4951 {
50- if ( selectedAssetPath . DirectoryExists ( ) )
52+ selectedObject = AssetDatabase . LoadMainAssetAtPath ( path . ToString ( ) ) ;
53+
54+ if ( selectedObjectPath . DirectoryExists ( ) )
5155 {
5256 nodeIcon = Styles . FolderIcon ;
5357 }
5458 else
5559 {
56- nodeIcon = UnityEditorInternal . InternalEditorUtility . GetIconForFile ( selectedAssetPath . ToString ( ) ) ;
60+ nodeIcon = UnityEditorInternal . InternalEditorUtility . GetIconForFile ( selectedObjectPath . ToString ( ) ) ;
5761 }
58- }
5962
60- if ( nodeIcon != null )
61- {
6263 nodeIcon . hideFlags = HideFlags . HideAndDontSave ;
6364 }
6465
6566 selectedIcon = nodeIcon ;
6667
67- Repository . UpdateFileLog ( selectedAssetPath )
68+ Repository . UpdateFileLog ( selectedObjectPath )
6869 . Start ( ) ;
6970 }
7071
@@ -129,16 +130,15 @@ public override void OnSelectionChange()
129130
130131 if ( ! locked )
131132 {
132- var assetGuid = Selection . assetGUIDs . FirstOrDefault ( ) ;
133-
134- selectedAssetPath = NPath . Default ;
135- if ( assetGuid != null )
133+ selectedObject = Selection . activeObject ;
134+ selectedObjectPath = NPath . Default ;
135+ if ( selectedObject != null )
136136 {
137- selectedAssetPath = AssetDatabase . GUIDToAssetPath ( assetGuid )
137+ selectedObjectPath = AssetDatabase . GetAssetPath ( selectedObject )
138138 . ToNPath ( ) ;
139139 }
140140
141- SetSelectedPath ( selectedAssetPath ) ;
141+ SetSelectedPath ( selectedObjectPath ) ;
142142 }
143143 }
144144
@@ -155,13 +155,16 @@ public override void OnUI()
155155 {
156156 base . OnUI ( ) ;
157157
158- GUILayout . BeginVertical ( Styles . HeaderStyle ) ;
158+ if ( selectedObject != null )
159159 {
160- DoHeaderGUI ( ) ;
160+ GUILayout . BeginVertical ( Styles . HeaderStyle ) ;
161+ {
162+ DoHeaderGUI ( ) ;
161163
162- fileHistoryView . OnGUI ( ) ;
164+ fileHistoryView . OnGUI ( ) ;
165+ }
166+ GUILayout . EndVertical ( ) ;
163167 }
164- GUILayout . EndVertical ( ) ;
165168 }
166169
167170 private void MaybeUpdateData ( )
@@ -201,16 +204,23 @@ private void DoHeaderGUI()
201204 {
202205 GUILayout . BeginHorizontal ( Styles . HeaderBoxStyle ) ;
203206 {
204- GUILayout . BeginVertical ( ) ;
205- {
206- GUILayout . Space ( 3 ) ;
207+ var iconWidth = 32 ;
208+ var iconHeight = 32 ;
209+
210+ GUILayout . Label ( selectedIcon , GUILayout . Height ( iconWidth ) , GUILayout . Width ( iconHeight ) ) ;
207211
208- var iconWidth = 32 ;
209- var iconHeight = 32 ;
212+ GUILayout . Label ( selectedObjectPath , Styles . FileHistoryLogTitleStyle ) ;
210213
211- GUILayout . Label ( selectedIcon , GUILayout . Height ( iconWidth ) , GUILayout . Width ( iconHeight ) ) ;
214+ GUILayout . FlexibleSpace ( ) ;
215+
216+ GUILayout . BeginVertical ( ) ;
217+ {
218+ GUILayout . Space ( 16 ) ;
212219
213- GUILayout . Label ( selectedAssetPath , Styles . Label ) ;
220+ if ( GUILayout . Button ( "Show in Project" ) )
221+ {
222+ EditorGUIUtility . PingObject ( selectedObject ) ;
223+ }
214224 }
215225 GUILayout . EndVertical ( ) ;
216226 }
0 commit comments