Skip to content

Commit 45d1df2

Browse files
committed
Basic implementation of the ScriptableObjectCreationWindow
1 parent aeb191f commit 45d1df2

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Reflection;
3+
4+
using UnityEditor;
5+
using UnityEditor.IMGUI.Controls;
6+
using UnityEngine;
7+
8+
namespace Toolbox.Editor.Windows
9+
{
10+
public class ScriptableObjectCreationWindow : EditorWindow
11+
{
12+
private SearchField searchField;
13+
14+
15+
[MenuItem("Assets/Create/ScriptableObject Creation Window", priority = 5)]
16+
internal static void Initialize()
17+
{
18+
var window = GetWindow<ScriptableObjectCreationWindow>();
19+
window.titleContent = new GUIContent("ScriptableObject Creation Window");
20+
window.Show();
21+
}
22+
23+
24+
private void OnEnable()
25+
{
26+
searchField = new SearchField();
27+
}
28+
29+
private void OnGUI()
30+
{
31+
using (new EditorGUILayout.HorizontalScope())
32+
{
33+
using (new EditorGUILayout.VerticalScope())
34+
{
35+
DrawSearchPanel();
36+
}
37+
38+
using (new EditorGUILayout.VerticalScope())
39+
{
40+
DrawCreatePanel();
41+
}
42+
}
43+
}
44+
45+
private void DrawSearchPanel()
46+
{
47+
var rect = GUILayoutUtility.GetRect(100.0f, 16.0f);
48+
searchField.OnGUI(rect, string.Empty);
49+
}
50+
51+
private void DrawCreatePanel()
52+
{
53+
if (GUILayout.Button("Create"))
54+
{
55+
Debug.Log(GetActiveFolderPath());
56+
}
57+
}
58+
59+
private static string GetActiveFolderPath()
60+
{
61+
Type projectWindowUtilType = typeof(ProjectWindowUtil);
62+
MethodInfo getActiveFolderPath = projectWindowUtilType.GetMethod("GetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic);
63+
object obj = getActiveFolderPath.Invoke(null, new object[0]);
64+
string pathToCurrentFolder = obj.ToString();
65+
return pathToCurrentFolder;
66+
}
67+
}
68+
}

Assets/Editor Toolbox/Editor/Windows/ScriptableObjectCreationWindow.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)