- Home /
How do I bring up a dialog to let the user choose an asset?
I am writing an editor script that allows the user to set all the Physic materials on the selected objects' colliders. What is the easiest way to bring up a dialog to let the user choose the material? Preferably, I would like to use the same dialog that Unity uses, i.e. this one:
Answer by qJake · Aug 24, 2010 at 09:17 AM
Just have a public field inside your custom inspector or wizard or whatever. When the user clicks it to choose the material, the dialog will pop up. As far as I know, there's no way to just "show" that dialog, you need to do it through an inspector or editor window or wizard.
I managed to get the selector to pop up using System.Reflection to access the UnityEditor.ObjectSelector class, but I couldn't get the selection to actually update a property of my object, at which point I gave up.
Answer by Eric5h5 · Aug 24, 2010 at 09:59 AM
EdiorUtility.OpenFilePanel()
Thanks, Eric5h5... unfortunately this is not quite what I want - for example, it won't allow you to set a Physic material directly, since it provides only access to a file path.