- Home /
Open ObjectSelector window from Editor Script
I'm trying to replicate the Material ObjectField seen in the Inspector, except that I also want to view the material modifications to the texture. I've got everything working except for the Select button, which needs to open an Object Picker window. I cannot figure out how to open this window without using the default ObjectField class, which I can't use because it doesn't offer an equivalent to EditorGUI.DrawPreviewTexture().
What I've tried (unsuccessfully) thus far:
Resizing the ObjectField to fit in that small "Select" rectangle
Manually opening the ObejectPicker window:
EditorWindow.GetWindow(typeof(ObjectSelector), true, "Object Picker", true);
I guess ObjectSelector is hiding somewhere, because I can't seem to figure out what it inherits from.
Answer by karl_ · Jul 22, 2013 at 02:16 PM
Unity 4.2 exposes this in the Editor API:
Editor: Added EditorGUIUtility.ShowObjectPicker to let editor extensions use it on demand.
Answer by spectre1989 · Jul 14, 2013 at 07:52 PM
Bit of a necropost, but I was looking to do this too. I had a look around the assembly using ILSpy, and ObjectSelector is an internal class, and you can use it with reflection to call all the methods you need, but it's very unwieldy. I'd just recommend using FindObjectsOfType and sticking the results in a window.
Your answer
![](https://koobas.hobune.stream/wayback/20220613084816im_/https://answers.unity.com/themes/thub/images/avi.jpg)