Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestEditorWindow : UnityEditor.EditorWindow {
- [MenuItem ("Window/My Window")]
- static void Init () {
- // Get existing open window or if none, make a new one:
- var window = (TestEditorWindow)EditorWindow.GetWindow (typeof (TestEditorWindow));
- window.Show();
- }
- private int index = 0;
- public void OnGUI() {
- var padding = 5;
- var width = Screen.width - 2*padding;
- var lineHeight = EditorGUIUtility.singleLineHeight;
- var audioclipNames = FileNamesFromFolder<AudioClip>("Audiofiles");
- if(audioclipNames.Length <= 0) return;
- index = EditorGUI.Popup(new Rect(padding, padding, width, lineHeight), "test: ", index, audioclipNames);
- }
- public string[] FileNamesFromFolder<T>(string folderpath) where T : UnityEngine.Object {
- var allfiles = Resources.LoadAll<T>(folderpath);
- return allfiles.Select(obj => obj.name).ToArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement