Hi there, I want to make a little menu that you can open by pressing a key, and then you can search for a certain thing that you can then spawn. Spawning is not the problem but how do i make this search window? I totally don't understand the UI system. Hope you help, ~Glemau
Your window has to derive from EditorWindow, your GUI code goes into OnGUI, you bind the window to a hotkey through the MenuItem attribute. Also make sure to place the class somewhere inside the Assets/Editor folder, or at least have a parent folder named Editor. The following example will show up when pressing CTRL+T (on windows, CMD+T on Mac). Code (CSharp): using UnityEngine; using UnityEditor; class TestWindow : EditorWindow { string searchText; void OnGUI() { searchText = EditorGUILayout.TextField( "Search text", searchText ); if(GUILayout.Button("Search")) { // your code here } } [MenuItem("Window/test window %t")] static void SpawnWindow() { GetWindow<TestWindow>(); } }
I think this is for the Editor right? I meant Ingame. but its a good thing its just not what i wanted but thanks for the answer. ~Glemau
Right, this is editor code. To use it ingame, turn the class into a monobehaviour, put it into an empty scene object, and activate the object only when you want to display the menu. Better yet, use the new UGUI system.