@@ -37,34 +37,35 @@ private static bool GitFileHistoryValidation()
37
37
38
38
[ SerializeField ] private bool locked ;
39
39
[ SerializeField ] private FileHistoryView fileHistoryView = new FileHistoryView ( ) ;
40
- [ SerializeField ] private NPath selectedAssetPath ;
40
+ [ SerializeField ] private UnityEngine . Object selectedObject ;
41
+ [ SerializeField ] private NPath selectedObjectPath ;
41
42
42
43
public void SetSelectedPath ( NPath path )
43
44
{
44
- selectedAssetPath = path ;
45
+ selectedObjectPath = path ;
46
+ selectedObject = null ;
45
47
46
48
Texture nodeIcon = null ;
47
49
48
- if ( selectedAssetPath != NPath . Default )
50
+ if ( selectedObjectPath != NPath . Default )
49
51
{
50
- if ( selectedAssetPath . DirectoryExists ( ) )
52
+ selectedObject = AssetDatabase . LoadMainAssetAtPath ( path . ToString ( ) ) ;
53
+
54
+ if ( selectedObjectPath . DirectoryExists ( ) )
51
55
{
52
56
nodeIcon = Styles . FolderIcon ;
53
57
}
54
58
else
55
59
{
56
- nodeIcon = UnityEditorInternal . InternalEditorUtility . GetIconForFile ( selectedAssetPath . ToString ( ) ) ;
60
+ nodeIcon = UnityEditorInternal . InternalEditorUtility . GetIconForFile ( selectedObjectPath . ToString ( ) ) ;
57
61
}
58
- }
59
62
60
- if ( nodeIcon != null )
61
- {
62
63
nodeIcon . hideFlags = HideFlags . HideAndDontSave ;
63
64
}
64
65
65
66
selectedIcon = nodeIcon ;
66
67
67
- Repository . UpdateFileLog ( selectedAssetPath )
68
+ Repository . UpdateFileLog ( selectedObjectPath )
68
69
. Start ( ) ;
69
70
}
70
71
@@ -129,16 +130,15 @@ public override void OnSelectionChange()
129
130
130
131
if ( ! locked )
131
132
{
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 )
136
136
{
137
- selectedAssetPath = AssetDatabase . GUIDToAssetPath ( assetGuid )
137
+ selectedObjectPath = AssetDatabase . GetAssetPath ( selectedObject )
138
138
. ToNPath ( ) ;
139
139
}
140
140
141
- SetSelectedPath ( selectedAssetPath ) ;
141
+ SetSelectedPath ( selectedObjectPath ) ;
142
142
}
143
143
}
144
144
@@ -155,13 +155,16 @@ public override void OnUI()
155
155
{
156
156
base . OnUI ( ) ;
157
157
158
- GUILayout . BeginVertical ( Styles . HeaderStyle ) ;
158
+ if ( selectedObject != null )
159
159
{
160
- DoHeaderGUI ( ) ;
160
+ GUILayout . BeginVertical ( Styles . HeaderStyle ) ;
161
+ {
162
+ DoHeaderGUI ( ) ;
161
163
162
- fileHistoryView . OnGUI ( ) ;
164
+ fileHistoryView . OnGUI ( ) ;
165
+ }
166
+ GUILayout . EndVertical ( ) ;
163
167
}
164
- GUILayout . EndVertical ( ) ;
165
168
}
166
169
167
170
private void MaybeUpdateData ( )
@@ -201,16 +204,23 @@ private void DoHeaderGUI()
201
204
{
202
205
GUILayout . BeginHorizontal ( Styles . HeaderBoxStyle ) ;
203
206
{
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 ) ) ;
207
211
208
- var iconWidth = 32 ;
209
- var iconHeight = 32 ;
212
+ GUILayout . Label ( selectedObjectPath , Styles . FileHistoryLogTitleStyle ) ;
210
213
211
- GUILayout . Label ( selectedIcon , GUILayout . Height ( iconWidth ) , GUILayout . Width ( iconHeight ) ) ;
214
+ GUILayout . FlexibleSpace ( ) ;
215
+
216
+ GUILayout . BeginVertical ( ) ;
217
+ {
218
+ GUILayout . Space ( 16 ) ;
212
219
213
- GUILayout . Label ( selectedAssetPath , Styles . Label ) ;
220
+ if ( GUILayout . Button ( "Show in Project" ) )
221
+ {
222
+ EditorGUIUtility . PingObject ( selectedObject ) ;
223
+ }
214
224
}
215
225
GUILayout . EndVertical ( ) ;
216
226
}
0 commit comments