Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solutena/getassetlist
https://github.com/solutena/getassetlist
assets customeditor unity
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/solutena/getassetlist
- Owner: solutena
- Created: 2022-12-05T13:34:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-13T01:01:21.000Z (6 months ago)
- Last Synced: 2024-05-13T02:23:58.243Z (6 months ago)
- Topics: assets, customeditor, unity
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GetAssetList 함수
```
using System.Linq;public static List GetAssetList(string path, string filter)
{
List assets = AssetDatabase.FindAssets(filter, new[] { path }).ToList();
return assets.ConvertAll(guid => AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)));
}
```에셋 경로 내의 리스트를 가져와 커스텀 에디터에서 활용 할 수 있습니다.
## 예제
```
#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();
}List 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(path + list[select].name + ".cs");
AssetDatabase.OpenAsset(script);
}
}public static List GetAssetList(string path, string filter)
{
List assets = AssetDatabase.FindAssets(filter, new[] { path }).ToList();
return assets.ConvertAll(guid => AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)));
}
}
#endif
```
![image](https://user-images.githubusercontent.com/22467083/205658292-4d45d245-48c5-420e-af16-db3899611da7.png)예제에선 Asset/Script/Item 경로의 스크립트들을 가져옵니다.
Open 버튼을 통해서 스크립트를 열 수 있습니다.
스크립트로 구현된 아이템, 스킬 등을 편리하게 관리 할 수 있다.