private void PickFromFolder() { string dir = AssetDatabase.GetAssetPath(_collection); dir = Directory.GetParent(dir).FullName; dir = EditorUtility.OpenFolderPanel("open", dir, ""); if (string.IsNullOrEmpty(dir)) { return; } dir = EditorFileTools.GetPath(dir); if (!Directory.Exists(dir)) { return; } List <SpriteInfo> sprites = new List <SpriteInfo>(); sprites.AddRange(_collection.sprites); string[] files = Directory.GetFiles(dir).Where(a => a.EndsWith(".jpg") || a.EndsWith(".png")).ToArray(); for (int i = 0; i < files.Length; i++) { string f = files[i]; HandlerFile(f, sprites); } _collection.sprites = sprites.ToArray(); CollectionToList(); EditorUtility.SetDirty(_collection); }
private void PickFromFile() { string dir = AssetDatabase.GetAssetPath(_collection); dir = Directory.GetParent(dir).FullName; string file = EditorUtility.OpenFilePanelWithFilters("Pick File", dir, new[] { "Image Files", "png,jpg,tga" }); if (string.IsNullOrEmpty(file)) { return; } file = EditorFileTools.GetPath(file); List <SpriteInfo> sprites = new List <SpriteInfo>(); sprites.AddRange(_collection.sprites); HandlerFile(file, sprites); _collection.sprites = sprites.ToArray(); CollectionToList(); EditorUtility.SetDirty(_collection); }