public void Start(string targetPath, bool isRecursive, ResultCallback callback) { if (!IsInitialized) { return; } if (string.IsNullOrEmpty(targetPath)) { return; } if (targetPath.StartsWith("Packages/")) { return; } // var callbackTarget = callback.Target as UnityObject; // if (callbackTarget == null) // { // throw new Exception("callback.Target is not UnityObject"); // } lock (sync) { CancelImpl(); EnqueueProcess(targetPath, isRecursive, callback); StartWorker(); } AssetDependencyDatabase.SetScanPaused(true); AssetDependencyDatabase.EnqueueScanDependency(targetPath); }
void ReadProcessOutput() { try { IsSearching = true; while (true) { if (Thread.CurrentThread.ManagedThreadId != workerId) { return; } ReferenceSearchEngineProcess p; lock (sync) { if (processQueue.Count == 0) { AssetDependencyDatabase.SetScanPaused(false); return; } p = processQueue[0]; processQueue.RemoveAt(0); currentProcess = p; p.StartProcess(); } if (Thread.CurrentThread.ManagedThreadId != workerId) { return; } p.WaitForComplete(); if (Thread.CurrentThread.ManagedThreadId != workerId) { return; } lock (sync) { currentProcess = null; } } } catch (ThreadAbortException) { } catch (System.Exception e) { Log(e.ToString()); } finally { IsSearching = false; } }
public void FoundReference(ReferenceSearchEngineProcess process, string objectPath, string targetPath) { // var o = process.Callback.Target as UnityObject; // if (o == null) // { // return; // } if (objectPath.StartsWith(Root)) { objectPath = objectPath.Substring(objectPath.Length + 1); } process.Callback(objectPath); if (process.IsRecursive && !targetPath.StartsWith("ProjectSettings/")) { EnqueueProcess(objectPath, process.IsRecursive, process.Callback, process.Results); } if (process.Results.Count > 5) { AssetDependencyDatabase.SetScanPaused(false); } AssetDependencyDatabase.EnqueueScanDependency(objectPath); }