浏览代码

Improved SOs quick access tool

/main
HarshNarayanJha 4 年前
当前提交
8c34e2b3
共有 1 个文件被更改,包括 59 次插入42 次删除
  1. 101
      UOP1_Project/Assets/Scripts/Editor/SOsQuickAccessToolWindow.cs

101
UOP1_Project/Assets/Scripts/Editor/SOsQuickAccessToolWindow.cs


{
assetSearchFolders = new string[1];
assetSearchFolders[0] = "Assets/ScriptableObjects";
FindAllSOs();
}
void OnFocus()
{
FindAllSOs();
[MenuItem("Tools/Quick Access Tool")]
[MenuItem("Tools/SOs Quick Access Tool")]
GetWindow<SOsQuickAccessToolWindow>("Quick Access Tool");
GetWindow<SOsQuickAccessToolWindow>("SOs Quick Access Tool");
// All finding work #1
GUILayout.Space(EditorGUIUtility.singleLineHeight);
if (GUILayout.Button("Refresh All"))
{
FindAllSOs();
FindDisplaySOs();
}
GUILayout.Space(EditorGUIUtility.singleLineHeight);
GUILayout.Label("Please select a Scriptable Object Type To Search For");
GUILayout.Space(EditorGUIUtility.singleLineHeight);
DrawSOsPicker();
GUILayout.Space(EditorGUIUtility.singleLineHeight * 3f);
DrawSOsList();
}
void DrawSOsPicker()
{
EditorGUI.BeginChangeCheck();
selected = EditorGUILayout.Popup("Scriptable Object Types", selected, SOTypes.ToArray());
if (EditorGUI.EndChangeCheck())
{
FindDisplaySOs();
}
}
void DrawSOsList()
{
scroll = GUILayout.BeginScrollView(scroll);
for (int i=0; i< displayObjectsGUIDs.Length; i++)
{
GUILayout.Label(i+1 + ". " + displayObjects[i].name);
if (GUILayout.Button("Locate Quickly"))
{
EditorUtility.FocusProjectWindow();
EditorGUIUtility.PingObject(displayObjects[i]);
}
GUILayout.Space(EditorGUIUtility.singleLineHeight);
}
GUILayout.EndScrollView();
}
void FindAllSOs()
{
objectsGUIDs = AssetDatabase.FindAssets("t:ScriptableObject", assetSearchFolders) as string[];
objectsPaths = new string[objectsGUIDs.Length];

SOTypes.Add(objects[i].GetType().ToString());
}
}
// End #1
GUILayout.Space(EditorGUIUtility.singleLineHeight * 2f);
GUILayout.Label("Please select a Scriptable Object Type To Search For...");
GUILayout.Space(EditorGUIUtility.singleLineHeight);
DrawSOsPicker();
GUILayout.Space(EditorGUIUtility.singleLineHeight * 3f);
DrawSOsList();
void DrawSOsPicker()
{
EditorGUI.BeginChangeCheck();
selected = EditorGUILayout.Popup("Scriptable Object Types", selected, SOTypes.ToArray());
if (EditorGUI.EndChangeCheck())
{
DrawSOsList();
}
}
void DrawSOsList()
void FindDisplaySOs()
{
if (displayObjects != null)
{

displayObjectsPaths.Add(AssetDatabase.GUIDToAssetPath(displayObjectsGUIDs[i]));
displayObjects.Add(AssetDatabase.LoadAssetAtPath(displayObjectsPaths[i], typeof(ScriptableObject)) as ScriptableObject);
}
scroll = GUILayout.BeginScrollView(scroll);
for (int i=0; i< displayObjectsGUIDs.Length; i++)
{
GUILayout.Label(i+1 + ". " + displayObjects[i].name);
if (GUILayout.Button("Locate"))
{
EditorUtility.FocusProjectWindow();
EditorGUIUtility.PingObject(displayObjects[i]);
}
GUILayout.Space(EditorGUIUtility.singleLineHeight);
}
GUILayout.EndScrollView();
}
}
正在加载...
取消
保存