Skip to content

Commit 424c6cd

Browse files
committed
finished the tabs
1 parent 9e52e68 commit 424c6cd

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

Editor/DrawerMenu.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ public class DrawerMenu : EditorWindow
1313
Vector2 scrollPos;
1414
static Drawer[] drawers;
1515
static DrawerOption[] options;
16-
public static void ShowWindow(Drawer[] drawer, DrawerOption[] _keys) {
16+
static DrawerOption[] mostUsedKeys;
17+
static DrawerOption[] numbers;
18+
public static void ShowWindow(Drawer[] drawer, DrawerOption[] _keys, DrawerOption[] _mostUsedKeys, DrawerOption[] _numbers) {
1719
var window = GetWindow<DrawerMenu>();
1820
window.titleContent = new GUIContent("Drawer menu");
1921
window.Show();
2022
window.minSize = new Vector2(400,180);
2123
options = _keys;
2224
drawers = drawer;
25+
mostUsedKeys = _mostUsedKeys;
26+
numbers = _numbers;
2327
}
2428

2529
void OnGUI()
@@ -30,26 +34,30 @@ void OnGUI()
3034
s[i] = drawers[i].name;
3135
}
3236
tab = GUILayout.Toolbar(tab, s);
33-
switch(tab){
34-
case 0:
35-
GUILayout.BeginVertical(EditorStyles.toolbar);
36-
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(400), GUILayout.Height(500));
37-
for (int i = 0; i < options.Length; i++)
38-
{
39-
options[i].Refresh(i);
40-
if(GUILayout.Button(options[i].name, EditorStyles.toolbarButton)){
41-
options[i].onGUI();
42-
options[i].Update();
43-
};
44-
GUILayout.FlexibleSpace();
45-
}
46-
GUILayout.EndVertical();
47-
GUILayout.EndScrollView();
48-
break;
49-
case 1:
50-
Debug.Log("Test");
51-
break;
52-
}
37+
Draw(tab);
38+
}
39+
40+
void Draw(int r){
41+
var groups = new List<DrawerOption[]>();
42+
groups.Add(options);
43+
groups.Add(mostUsedKeys);
44+
groups.Add(numbers);
45+
46+
var o = groups[r];
47+
48+
GUILayout.BeginVertical(EditorStyles.toolbar);
49+
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(400), GUILayout.Height(500));
50+
for (int i = 0; i < o.Length; i++)
51+
{
52+
o[i].Refresh(i);
53+
if(GUILayout.Button(o[i].name, EditorStyles.toolbarButton)){
54+
o[i].onGUI();
55+
o[i].Update();
56+
};
57+
GUILayout.FlexibleSpace();
58+
}
59+
GUILayout.EndVertical();
60+
GUILayout.EndScrollView();
5361
}
5462
}
5563
[System.Serializable]

Editor/KeyCodeDrawer.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ private void selectKey()
124124
KeyCode.Alpha9,
125125
};
126126
var drawer = new DrawerOption[keyCodes.Length];
127+
var drawerUsedKeys = new DrawerOption[mostUsedKeys.Length];
128+
var drawerNumbers = new DrawerOption[numberKeys.Length];
127129

128130

129131

@@ -136,9 +138,25 @@ private void selectKey()
136138
p.enumValueIndex = 4;}, p, k);
137139
keys[i++] = k;
138140
}
141+
142+
int ii = 0;
143+
foreach(KeyCode k in mostUsedKeys){
144+
drawerUsedKeys[ii] = new DrawerOption<KeyCode>(()=>mostUsedKeys, k.ToString(), key => {
145+
146+
}, p, k);
147+
ii++;
148+
}
149+
150+
int iii = 0;
151+
foreach(KeyCode k in numberKeys){
152+
drawerNumbers[iii] = new DrawerOption<KeyCode>(()=>numberKeys, k.ToString(), key => {
153+
154+
}, p, k);
155+
iii++;
156+
}
139157

140158

141-
DrawerMenu.ShowWindow(new Drawer[]{new Drawer("All Keys"), new Drawer("Most Used")}, drawer);
159+
DrawerMenu.ShowWindow(new Drawer[]{new Drawer("All Keys"), new Drawer("Most Used"), new Drawer("Numbers")}, drawer, drawerUsedKeys, drawerNumbers);
142160

143161
// Display the selection window to pick a keycode.
144162
/*SelectionWindow.Show(new Tab<KeyCode>(

Samples/EntityExamples.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ MonoBehaviour:
638638
inputData:
639639
profile:
640640
- inputName: Interaction
641-
inputKey: 42
641+
inputKey: 51
642642
joystickKey: 0
643643
- inputName: Pause
644644
inputKey: 279

0 commit comments

Comments
 (0)