internal void ReadFromProject(bool force) { var paths = AssetDatabase.GetAllAssetPaths().ToList(); paths.RemoveAll(item => !item.StartsWith("Assets/")); var guids = paths.Select(item => AssetDatabase.AssetPathToGUID(item)).ToArray(); cacheStamp++; // Check for new assets for (var i = 0; i < guids.Length; i++) { if (!FR2_Asset.IsValidGUID(guids[i])) { continue; } FR2_Asset asset; if (AssetMap.TryGetValue(guids[i], out asset)) { asset.cacheStamp = cacheStamp; continue; } ; // New asset AddAsset(guids[i]); } // Check for deleted assets for (var i = AssetList.Count - 1; i >= 0; i--) { if (AssetList[i].cacheStamp != cacheStamp) { RemoveAsset(AssetList[i]); } } // Refresh definition list for (var i = 0; i < AssetList.Count; i++) { AddSymbols(AssetList[i]); } if (force) { timeStamp = FR2_Unity.Epoch(DateTime.Now); workCount += AssetMap.Count; queueLoadContent.AddRange(AssetMap.Values.ToList()); } }
internal void LoadAssetInfo() { assetPath = AssetDatabase.GUIDToAssetPath(guid); if (string.IsNullOrEmpty(assetPath)) { state = FR2_AssetState.MISSING; return; } if (!assetPath.StartsWith("Assets/", StringComparison.Ordinal)) { #if FR2_DEBUG Debug.LogWarning("Something wrong ! Should never be here !\n" + assetPath + "\n" + guid); #endif return; } var info = new FileInfo(assetPath); assetName = info.Name; extension = info.Extension.ToLower(); assetFolder = assetPath.Substring(7, Mathf.Max(0, assetPath.Length - assetName.Length - 7)); // 7 = "Assets/".Length loaded = stamp == FR2_Unity.Epoch(info.LastWriteTime); if (Directory.Exists(info.FullName)) { type = FR2_AssetType.FOLDER; } else if (File.Exists(info.FullName)) { if (type == FR2_AssetType.UNKNOWN) { GuessAssetType(); } fileSize = info.Length; inEditor = assetPath.Contains("/Editor/"); inResources = assetPath.Contains("/Resources/"); inStreamingAsset = assetPath.Contains("/StreamingAsset/"); inPlugins = assetPath.StartsWith("Assets/Plugins/", StringComparison.Ordinal); fileInfoHash = info.Length + info.Extension; } else { state = FR2_AssetState.MISSING; } }
private static void FoundCache(bool savePrefs, bool writeFile) { var elapseTime = FR2_Unity.Epoch(DateTime.Now) - _cache.timeStamp; _cache.Check4Changes(!EditorApplication.isPlaying, elapseTime > FORCE_REFRESH_DURATION); _cachePath = AssetDatabase.GetAssetPath(_cache); _cacheGUID = AssetDatabase.AssetPathToGUID(_cachePath); if (savePrefs) { EditorPrefs.SetString("fr2_cache.guid", _cacheGUID); } if (writeFile) { File.WriteAllText("Library/fr2_cache.guid", _cacheGUID); } }
internal void LoadContent(bool force) { if (state == FR2_AssetState.NEW) { LoadAssetInfo(); } if (IsMissing || type == FR2_AssetType.NON_READABLE) { return; } if (type == FR2_AssetType.DLL) { #if FR2_DEBUG Debug.LogWarning("Parsing DLL not yet supportted "); #endif return; } if (loaded && !force) { return; } // Check for file / folder changes & validate if file / folder exist var newStamp = stamp; var exist = true; if (IsFolder) { var info = new DirectoryInfo(assetPath); exist = info.Exists; newStamp = FR2_Unity.Epoch(info.LastWriteTime); } else { var info = new FileInfo(assetPath); exist = info.Exists; newStamp = FR2_Unity.Epoch(info.LastWriteTime); } if (!exist) { state = FR2_AssetState.MISSING; return; } loaded = true; if (newStamp == stamp && !force) { #if FR2_DEBUG Debug.Log("Unchanged : " + stamp + ":" + assetName + ":" + type); #endif return; // nothing changed } stamp = newStamp; UseGUIDs.Clear(); if (IsFolder) { LoadFolder(); } else if (IsReferencable) { LoadYAML(); } else if (IsBinaryAsset) { LoadBinaryAsset(); } else if (IsScript) { LoadScript(); } }