-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.cs
More file actions
37 lines (33 loc) · 1.01 KB
/
Example.cs
File metadata and controls
37 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
public class CommandWindow : EditorWindow
{
[MenuItem("Window/CommandWindow")]
static void GetWindow()
{
GetWindow<CommandWindow>();
}
List<Object> list;
int select = 0;
string path = "Assets/Script/Item/";
string filter = "t:MonoScript";
private void OnGUI()
{
list = GetAssetList(path, filter);
select = GUILayout.SelectionGrid(select, list.ConvertAll(obj => obj.name).ToArray(), 1, "PreferencesKeysElement");
if (GUILayout.Button("Open"))
{
Object script = AssetDatabase.LoadAssetAtPath<MonoScript>(path + list[select].name + ".cs");
AssetDatabase.OpenAsset(script);
}
}
public static List<Object> GetAssetList(string path, string filter)
{
List<string> assets = AssetDatabase.FindAssets(filter, new[] { path }).ToList();
return assets.ConvertAll(guid => AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(guid)));
}
}
#endif