Esempio n. 1
0
        private static void ScanAssetDatabase(ProgressBarEnum <RefreshSteps> mainProgress)
        {
            string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
            Dictionary <Guid, FileEntry> fileLookup   = Connection.Table <FileEntry>().ToDictionary(f => f.Guid);
            ProgressBarCounted           scanProgress = new ProgressBarCounted(mainProgress.StartStep(RefreshSteps.ScanFiles), allAssetPaths.Length);

            for (int i = 0; i < allAssetPaths.Length; i++)
            {
                string path = allAssetPaths[i];

                if (!IsValidFile(path))
                {
                    continue;
                }

                scanProgress.StartStep(i, "Scanning " + Path.GetFileNameWithoutExtension(path));
                Guid fileGuid = new Guid(AssetDatabase.AssetPathToGUID(path));
                fileLookup.Remove(fileGuid);
                UpdateAssetInGuidDatabase(path, fileGuid, false);
            }

            ProgressBarCounted deleteProgress = new ProgressBarCounted(mainProgress.StartStep(RefreshSteps.RemoveOldFiles), fileLookup.Count);
            int step = 0;

            foreach (FileEntry file in fileLookup.Values)
            {
                deleteProgress.StartStep(step, "Deleting " + file.DisplayPath);
                RemoveFileByGuid(file.Guid, file.Path);
                step++;
            }
        }
Esempio n. 2
0
        public static void Refresh()
        {
            Init();
            Connection.DropTable <FileEntry>();
            Connection.DropTable <UsageEntry>();

            Debug.Log($"<color=#cc00ff>AssetUsages</color> : Refreshing DB. (Last Refresh: {s_LastScan})");

            ProgressBarEnum <RefreshSteps> mainProgress = new ProgressBarEnum <RefreshSteps>("Refreshing Guid Reference Database", true);

            try {
                Connection.CreateTable <FileEntry>();
                Connection.CreateTable <UsageEntry>();
                Connection.CreateIndex(nameof(UsageEntry), "UserGuid");
                Connection.CreateIndex(nameof(UsageEntry), "ResourceGuid");
            }
            catch (DllNotFoundException) {
                s_Connection = null;
                Debug.LogError("<color=#cc00ff>AssetUsages</color> : DB refresh failed. SQLite DLL not found. Please restart Unity.");
                return;
            }

            mainProgress.StartStep(RefreshSteps.GatherFiles);
            DateTime startTime = DateTime.Now;

            Connection.BeginTransaction();

            try {
                //ScanFilesManually(mainProgress);
                ScanAssetDatabase(mainProgress);
            }
            catch (ProgressBar.UserCancelledException) {
                Debug.LogWarning("Scan incomplete due to cancellation.");
            }

            Connection.Commit();
            s_LastScan = startTime;
            EditorPrefs.SetString(kLastScanKey, s_LastScan.ToString(CultureInfo.InvariantCulture));
            mainProgress.Done();

            RaiseUpdated();
        }
Esempio n. 3
0
        /// <summary>
        /// 获取圆的 Thickness 类型的左边距值
        /// </summary>
        /// <param name="xName">圆的某一位置的X坐标名称</param>
        /// <returns>返回一个 Dictionary&lt;Thickness, double&gt; 类型的左边距值与当前位置时间间隔系数的字典对象</returns>
        private Dictionary <Thickness, double> GetEllipseLeftMargin(ProgressBarEnum xName)
        {
            double x     = 0d;
            double ratio = 0d;

            switch (xName)
            {
            case ProgressBarEnum.Start:
                x     = this.ActualWidth * ProgressBar.XRatio_Start;
                ratio = 0d;
                break;

            case ProgressBarEnum.MiddleLeft:
                x     = this.ActualWidth * ProgressBar.XRatio_MiddleLeft;
                ratio = 1d;
                break;

            case ProgressBarEnum.MiddleRight:
                x     = this.ActualWidth * ProgressBar.XRatio_MiddleRight;
                ratio = 3d;
                break;

            case ProgressBarEnum.End:
                x     = this.ActualWidth * ProgressBar.XRatio_End;
                ratio = 4d;
                break;

            default:
                x     = this.ActualWidth * ProgressBar.XRatio_Start;
                ratio = 0d;
                break;
            }
            Dictionary <Thickness, double> thicknessDic = new Dictionary <Thickness, double>();
            Thickness xTkn = new Thickness(x, 0, 0, 0);

            thicknessDic.Add(xTkn, ratio);
            return(thicknessDic);
        }