Skip to content

Commit 2611114

Browse files
committed
finished version v1.0.0
1 parent bf00e71 commit 2611114

3 files changed

Lines changed: 33 additions & 33 deletions

File tree

Editor/DrawerMenu.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace BigasTools.Editor{
1010
public class DrawerMenu : EditorWindow
1111
{
12+
Vector2 scrollPos;
1213
static DrawerOption[] options;
1314
public static void ShowWindow(DrawerOption[] _keys) {
1415
var window = GetWindow<DrawerMenu>();
@@ -20,7 +21,8 @@ public static void ShowWindow(DrawerOption[] _keys) {
2021

2122
void OnGUI()
2223
{
23-
GUILayout.BeginHorizontal(EditorStyles.toolbar);
24+
GUILayout.BeginVertical(EditorStyles.toolbar);
25+
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(400), GUILayout.Height(500));
2426
for (int i = 0; i < options.Length; i++)
2527
{
2628
options[i].Refresh(i);
@@ -30,7 +32,8 @@ void OnGUI()
3032
};
3133
GUILayout.FlexibleSpace();
3234
}
33-
35+
GUILayout.EndVertical();
36+
GUILayout.EndScrollView();
3437
}
3538
}
3639
[System.Serializable]
@@ -48,13 +51,16 @@ public class DrawerOption<T> : DrawerOption{
4851
private readonly SerializedProperty serializedProperty;
4952
private T[] values;
5053
private T value;
54+
private int selected;
55+
KeyCode _selectedKey;
5156

52-
public DrawerOption(Func<T[]> getValues, string name, Action<T> setValue, SerializedProperty serializedProperty)
57+
public DrawerOption(Func<T[]> getValues, string name, Action<T> setValue, SerializedProperty serializedProperty, KeyCode _selectedKey)
5358
{
5459
this.name = name;
5560
this.getValues = getValues;
5661
this.setValue = setValue;
5762
this.serializedProperty = serializedProperty;
63+
this._selectedKey = _selectedKey;
5864
}
5965

6066
public override void onGUI()
@@ -64,10 +70,28 @@ public override void onGUI()
6470
//setValue(value);
6571
}
6672
}
73+
void GetEnumIndex(){
74+
string _selectedKeyName = Enum.GetName(typeof(KeyCode), _selectedKey);
75+
var keyCodes = Enum.GetValues(typeof(KeyCode));
76+
77+
int index = 0;
78+
79+
// Find the index of the selected key name.
80+
foreach (string enumName in serializedProperty.enumNames) {
81+
82+
if (enumName == _selectedKeyName) {
83+
break;
84+
}
85+
86+
index++;
87+
}
88+
89+
serializedProperty.enumValueIndex = index;
90+
serializedProperty.serializedObject.ApplyModifiedProperties();
91+
}
6792
public override void Update()
6893
{
69-
serializedProperty.enumValueIndex = 14;
70-
Debug.Log(serializedProperty.serializedObject.ApplyModifiedProperties());
94+
GetEnumIndex();
7195
}
7296
void onValueGUI(T val){
7397
setValue(val);

Editor/KeyCodeDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private void selectKey()
9898
foreach (KeyCode k in keyCodes) {
9999
drawer[i] = new DrawerOption<KeyCode>(()=>keys, k.ToString(), key => {
100100
//_selectedKey = key;
101-
p.enumValueIndex = 4;}, p);
101+
p.enumValueIndex = 4;}, p, k);
102102
keys[i++] = k;
103103
}
104104

Samples/EntityExamples.unity

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ GameObject:
417417
- component: {fileID: 1742347590}
418418
- component: {fileID: 1742347589}
419419
- component: {fileID: 1742347588}
420-
- component: {fileID: 1742347592}
421420
m_Layer: 5
422421
m_Name: Canvas
423422
m_TagString: Untagged
@@ -506,29 +505,6 @@ RectTransform:
506505
m_AnchoredPosition: {x: 0, y: 0}
507506
m_SizeDelta: {x: 0, y: 0}
508507
m_Pivot: {x: 0, y: 0}
509-
--- !u!114 &1742347592
510-
MonoBehaviour:
511-
m_ObjectHideFlags: 0
512-
m_CorrespondingSourceObject: {fileID: 0}
513-
m_PrefabInstance: {fileID: 0}
514-
m_PrefabAsset: {fileID: 0}
515-
m_GameObject: {fileID: 1742347587}
516-
m_Enabled: 1
517-
m_EditorHideFlags: 0
518-
m_Script: {fileID: 11500000, guid: 9ce27d69e8fc57943908a4d8334575f7, type: 3}
519-
m_Name:
520-
m_EditorClassIdentifier:
521-
inputData:
522-
profile:
523-
- inputName: Interaction
524-
inputKey: 101
525-
joystickKey: 0
526-
- inputName: Pause
527-
inputKey: 39
528-
joystickKey: 4
529-
- inputName: Info
530-
inputKey: 13
531-
joystickKey: 5
532508
--- !u!1 &1878767017
533509
GameObject:
534510
m_ObjectHideFlags: 0
@@ -662,10 +638,10 @@ MonoBehaviour:
662638
inputData:
663639
profile:
664640
- inputName: Interaction
665-
inputKey: 39
641+
inputKey: 105
666642
joystickKey: 0
667643
- inputName: Pause
668-
inputKey: 27
644+
inputKey: 279
669645
joystickKey: 4
670646
- inputName: Info
671647
inputKey: 27
@@ -674,7 +650,7 @@ MonoBehaviour:
674650
inputKey: 39
675651
joystickKey: 6
676652
- inputName: Example1
677-
inputKey: 27
653+
inputKey: 39
678654
joystickKey: 10
679655
- inputName: dada
680656
inputKey: 39

0 commit comments

Comments
 (0)