Drag Drop Folder to Inspector View

Hi,

I have a script that contains an array of textures.
The number of textures can be large, so I dont wanna drag and drop every single image but the file content of a folder. how can i do this?

is there a way to do it without editor scripting?

if it has to be done via editor scripting: are there any useful tutorials about how to use the DragAndDrop class? how can i open a directory? there is a method OpenFilePanel - but i cant find something according for a directory.

thanks.

You could load them via Resources.Load during run-time. Note that your textures must be located in a folder called Resources for this to work. If you use multiple scenes, this will have the drawback that your textures will be included in every scene, even in those you don’t need them. If that’s a problem, your editor script would be a better idea.

But I would like to load them beforehand not during run-time.

You were asking for a way without editor scripting, which means run-time :P.

If it must happen at compile time, you’ll have to use an editor script.

Any particular reason why it must happen in the editor and not during run time? The textures must be loaded into memory one way or another, so I don’t believe it will make any difference for performance.

Ok, thanks.
I was hoping that i could possibly add a public object field or something like that from which i could extract a folder path or so. But yes, i could then also just load the files of the folder during runtime, u r right.

I would like to see the textures before run-time to be able to further edit the texture array.

So Editor-Scripting then. Can you tell me how i can open a directory by editor scripting? sth like the OpenFilePanel-method?

That makes sense.

You could use Resources.LoadAssetAtPath (editor mode only) to load the textures after picking the directory.

You might be able to use EditorUtility.OpenFilePanel to select the directory (although I never used this function, so I’m not sure if that will work).

For getting a listing of the contents of a directory, I don’t know any functionality within Unity. You’ll probably have to use Mono functions for that.