Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c98f73c

Browse files
Handling bulk lock and unlock operations with TaskQueue
1 parent 677740d commit c98f73c

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ProjectWindowInterface.cs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static bool IsObjectUnlocked(Object selected)
100100
[MenuItem(AssetsMenuRequestLock)]
101101
private static void ContextMenu_Lock()
102102
{
103-
// isBusy = true;
103+
isBusy = true;
104104

105105
var unlockedObjects = Selection.objects.Where(IsObjectUnlocked).ToArray();
106106
var tasks = unlockedObjects.Select(LockObject).ToArray();
@@ -111,14 +111,11 @@ private static void ContextMenu_Lock()
111111
taskQueue.Queue(task);
112112
}
113113

114-
taskQueue.Start();
115-
116-
// taskQueue.FinallyInUI((success, exception) =>
117-
// {
118-
// isBusy = false;
119-
// Selection.activeGameObject = null;
120-
// EditorApplication.RepaintProjectWindow();
121-
// }).Start();
114+
taskQueue.FinallyInUI((success, exception) =>
115+
{
116+
isBusy = false;
117+
Selection.activeGameObject = null;
118+
}).Start();
122119
}
123120

124121
private static ITask LockObject(Object selected)
@@ -164,7 +161,7 @@ private static bool IsObjectLocked(Object selected)
164161
[MenuItem(AssetsMenuReleaseLock, false, 1000)]
165162
private static void ContextMenu_Unlock()
166163
{
167-
// isBusy = true;
164+
isBusy = true;
168165

169166
var lockedObjects = Selection.objects.Where(IsObjectLocked).ToArray();
170167
var tasks = lockedObjects.Select(o => UnlockObject(o, false)).ToArray();
@@ -175,14 +172,11 @@ private static void ContextMenu_Unlock()
175172
taskQueue.Queue(task);
176173
}
177174

178-
taskQueue.Start();
179-
180-
// taskQueue.FinallyInUI((success, exception) =>
181-
// {
182-
// isBusy = false;
183-
// Selection.activeGameObject = null;
184-
// EditorApplication.RepaintProjectWindow();
185-
// }).Start();
175+
taskQueue.FinallyInUI((success, exception) =>
176+
{
177+
isBusy = false;
178+
Selection.activeGameObject = null;
179+
}).Start();
186180
}
187181

188182
[MenuItem(AssetsMenuReleaseLockForced, true, 1000)]
@@ -209,7 +203,7 @@ private static bool ContextMenu_CanUnlockForce()
209203
[MenuItem(AssetsMenuReleaseLockForced, false, 1000)]
210204
private static void ContextMenu_UnlockForce()
211205
{
212-
// isBusy = true;
206+
isBusy = true;
213207

214208
var lockedObjects = Selection.objects.Where(IsObjectLocked).ToArray();
215209
var tasks = lockedObjects.Select(o => UnlockObject(o, true)).ToArray();
@@ -220,14 +214,11 @@ private static void ContextMenu_UnlockForce()
220214
taskQueue.Queue(task);
221215
}
222216

223-
taskQueue.Start();
224-
225-
// taskQueue.FinallyInUI((success, exception) =>
226-
// {
227-
// isBusy = false;
228-
// Selection.activeGameObject = null;
229-
// EditorApplication.RepaintProjectWindow();
230-
// }).Start();
217+
taskQueue.FinallyInUI((success, exception) =>
218+
{
219+
isBusy = false;
220+
Selection.activeGameObject = null;
221+
}).Start();
231222
}
232223

233224
private static ITask UnlockObject(Object selected, bool force)

0 commit comments

Comments
 (0)