Exemplo n.º 1
0
        //===============
        // Setup
        //===============
        public static void Refresh()
        {
            var time = FileManager.GetTime();

            Event.Add("On Editor Update", FileManager.Monitor).SetPermanent();
            Event.Add("On Asset Changed", FileManager.Refresh).SetPermanent();
            FileManager.assets.Clear();
            FileManager.assetPaths.Clear();
            FileManager.filesByPath.Clear();
            FileManager.filesByType.Clear();
            FileManager.folders.Clear();
            FileManager.cache.Clear();
            FileManager.path = FileManager.dataPath.GetDirectory();
            var needsScan = !Application.isEditor || (Application.isEditor && !Utility.IsPlaying());

            if (needsScan)
            {
                FileManager.Scan(FileManager.path);
                FileManager.Scan(FileManager.path + "/Temp", true);
                if (FileManager.fullScan)
                {
                    FileManager.Scan(FileManager.dataPath, true);
                }
                FileManager.Save();
            }
            else
            {
                FileManager.Load();
            }
            if (FileManager.clock)
            {
                Debug.Log("[FileManager] : Refresh complete -- " + (FileManager.GetTime() - time) + " seconds.");
            }
        }
Exemplo n.º 2
0
 public static void Scan(string directory, bool deep = false)
 {
     if (!Directory.Exists(directory))
     {
         return;
     }
     string[] fileEntries   = Directory.GetFiles(directory);
     string[] folderEntries = Directory.GetDirectories(directory);
     if (!FileManager.monitors.ContainsKey(directory))
     {
         FileManager.monitors[directory] = new FileMonitor(directory);
     }
     FileManager.filesByPath.AddNew(directory);
     foreach (string filePath in fileEntries)
     {
         if (filePath.ContainsAny(".meta", "unitytemp", "unitylock"))
         {
             continue;
         }
         var path = filePath.Replace("\\", "/");
         FileManager.BuildCache(new FileData(path));
     }
     foreach (string folderPath in folderEntries)
     {
         if (folderPath.ContainsAny(".svn", "~"))
         {
             continue;
         }
         var path = folderPath.Replace("\\", "/");
         FileManager.BuildCache(new FileData(path, true));
         if (deep)
         {
             FileManager.Scan(path, true);
         }
     }
 }