public T GetLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject { LibraryCache presetLibraryCache = this.GetPresetLibraryCache(helper.fileExtensionWithoutDot); for (int i = 0; i < presetLibraryCache.loadedLibraryIDs.Count; i++) { if (presetLibraryCache.loadedLibraryIDs[i] == presetLibraryPathWithoutExtension) { if (presetLibraryCache.loadedLibraries[i] != null) { return(presetLibraryCache.loadedLibraries[i] as T); } presetLibraryCache.loadedLibraries.RemoveAt(i); presetLibraryCache.loadedLibraryIDs.RemoveAt(i); Debug.LogError("Invalid library detected: Reload " + presetLibraryCache.loadedLibraryIDs[i] + " from HDD"); break; } } T item = helper.Load(presetLibraryPathWithoutExtension); if (item != null) { item.hideFlags = this.libraryHideFlag; presetLibraryCache.loadedLibraries.Add(item); presetLibraryCache.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension); return(item); } return(null); }
public T GetLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject { PresetLibraryManager.LibraryCache presetLibraryCache = this.GetPresetLibraryCache(helper.fileExtensionWithoutDot); for (int index = 0; index < presetLibraryCache.loadedLibraryIDs.Count; ++index) { if (presetLibraryCache.loadedLibraryIDs[index] == presetLibraryPathWithoutExtension) { if ((Object)presetLibraryCache.loadedLibraries[index] != (Object)null) { return(presetLibraryCache.loadedLibraries[index] as T); } presetLibraryCache.loadedLibraries.RemoveAt(index); presetLibraryCache.loadedLibraryIDs.RemoveAt(index); Debug.LogError((object)("Invalid library detected: Reload " + presetLibraryCache.loadedLibraryIDs[index] + " from HDD")); break; } } T obj = helper.Load(presetLibraryPathWithoutExtension); if (!((Object)obj != (Object)null)) { return((T)null); } obj.hideFlags = this.libraryHideFlag; presetLibraryCache.loadedLibraries.Add((ScriptableObject)obj); presetLibraryCache.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension); return(obj); }
public T GetLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject { PresetLibraryManager.LibraryCache presetLibraryCache = this.GetPresetLibraryCache(helper.fileExtensionWithoutDot); int i = 0; while (i < presetLibraryCache.loadedLibraryIDs.Count) { if (presetLibraryCache.loadedLibraryIDs[i] == presetLibraryPathWithoutExtension) { if (presetLibraryCache.loadedLibraries[i] != null) { return(presetLibraryCache.loadedLibraries[i] as T); } presetLibraryCache.loadedLibraries.RemoveAt(i); presetLibraryCache.loadedLibraryIDs.RemoveAt(i); Debug.LogError("Invalid library detected: Reload " + presetLibraryCache.loadedLibraryIDs[i] + " from HDD"); break; } else { i++; } } T t = helper.Load(presetLibraryPathWithoutExtension); if (t != null) { t.hideFlags = this.libraryHideFlag; presetLibraryCache.loadedLibraries.Add(t); presetLibraryCache.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension); return(t); } return((T)((object)null)); }
public T GetLibrary <T>(ScriptableObjectSaveLoadHelper <T> helper, string presetLibraryPathWithoutExtension) where T : ScriptableObject { LibraryCache set = GetPresetLibraryCache(helper.fileExtensionWithoutDot); // Did we already load the lib for (int i = 0; i < set.loadedLibraryIDs.Count; ++i) { if (set.loadedLibraryIDs[i] == presetLibraryPathWithoutExtension) { if (set.loadedLibraries[i] != null) { return(set.loadedLibraries[i] as T); } else { // The library has been destroyed. Remove it from the lists so it can be reloaded set.loadedLibraries.RemoveAt(i); set.loadedLibraryIDs.RemoveAt(i); Debug.LogError("Invalid library detected: Reload " + set.loadedLibraryIDs[i] + " from HDD"); break; } } } // Debug.Log ("Not loaded yet " + typeof(T)); // Can we find on the hdd T library = helper.Load(presetLibraryPathWithoutExtension); if (library != null) { library.hideFlags = libraryHideFlag; // ensure correct hideflag with pre 4.3 versions set.loadedLibraries.Add(library); set.loadedLibraryIDs.Add(presetLibraryPathWithoutExtension); return(library); } // Debug.Log ("Not found on hdd"); return(null); }