Skip to content

Commit 59a510c

Browse files
committed
Select asset support in logs window
1 parent bb99f1d commit 59a510c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Editor/GUIUtils.cs

+6
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,11 @@ public static void Unstage(IEnumerable<(Module module, string[] files)> selectio
238238
foreach (var pair in selectionPerModule)
239239
_ = pair.module.Unstage(pair.files);
240240
}
241+
242+
public static void SelectAsset(string fullProjectPath)
243+
{
244+
string logicalPath = Utils.GetUnityLogicalPath(fullProjectPath);
245+
Selection.objects = new[] { AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(logicalPath) };
246+
}
241247
}
242248
}

Editor/GitLogWindow.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private void DrawFilesPanel(Module module, IEnumerable<string> selectedCommitHas
233233
if (selectedFiles != null)
234234
{
235235
var panelSize = new Vector2(position.width - InfoPanelWidth, FilesPanelHeight);
236-
treeViewFiles.Draw(panelSize, new[] { diffFiles }, (_) => ShowFileContextMenu(module, selectedFiles, selectedCommitHashes.First()));
236+
treeViewFiles.Draw(panelSize, new[] { diffFiles }, (_) => ShowFileContextMenu(module, selectedFiles, selectedCommitHashes.First()), (id) => SelectAsset(id, diffFiles));
237237
}
238238
else
239239
{
@@ -406,5 +406,12 @@ static void ShowFileContextMenu(Module module, IEnumerable<FileStatus> files, st
406406
});
407407
menu.ShowAsContext();
408408
}
409+
410+
static void SelectAsset(int id, GitStatus diffFiles)
411+
{
412+
var selectedAsset = diffFiles.Files.FirstOrDefault(x => x.FullPath.GetHashCode() == id);
413+
if (selectedAsset != null)
414+
GUIUtils.SelectAsset(selectedAsset.FullProjectPath);
415+
}
409416
}
410417
}

Editor/GitStagingWindow.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ record FilesSelection(ListState Unstaged, ListState Staged);
3939
LazyTreeView<GitStatus> treeViewStaged;
4040
string commitMessage = "";
4141
List<Task> tasksInProgress = new ();
42-
Dictionary<Module, FilesSelection> selectionPerModule = new ();
4342

4443
protected override void OnGUI()
4544
{
@@ -165,10 +164,7 @@ static void SelectAsset(int id)
165164
var statuses = Utils.GetGitModules().Select(x => x.GitStatus.GetResultOrDefault()).Where(x => x != null);
166165
var selectedAsset = statuses.SelectMany(x => x.Files).FirstOrDefault(x => x.FullPath.GetHashCode() == id);
167166
if (selectedAsset != null)
168-
{
169-
string logicalPath = Utils.GetUnityLogicalPath(selectedAsset.FullProjectPath);
170-
Selection.objects = new[] { AssetDatabase.LoadAssetAtPath<Object>(logicalPath) };
171-
}
167+
GUIUtils.SelectAsset(selectedAsset.FullProjectPath);
172168
}
173169

174170
static void ShowContextMenu(IEnumerable<Module> modules, List<FileStatus> files)

0 commit comments

Comments
 (0)