SHARE
TWEET

Untitled

a guest Apr 23rd, 2016 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public class TestEditorWindow : UnityEditor.EditorWindow {
  2.  
  3.             [MenuItem ("Window/My Window")]
  4.             static void Init () {
  5.                 // Get existing open window or if none, make a new one:
  6.                 var window = (TestEditorWindow)EditorWindow.GetWindow (typeof (TestEditorWindow));
  7.                 window.Show();
  8.             }
  9.  
  10.             private int index = 0;
  11.  
  12.             public void OnGUI() {
  13.                 var padding = 5;
  14.                 var width = Screen.width - 2*padding;
  15.                 var lineHeight = EditorGUIUtility.singleLineHeight;
  16.  
  17.                 var audioclipNames = FileNamesFromFolder<AudioClip>("Audiofiles");
  18.  
  19.                 if(audioclipNames.Length <= 0) return;
  20.  
  21.                 index = EditorGUI.Popup(new Rect(padding, padding, width, lineHeight), "test: ", index, audioclipNames);
  22.  
  23.             }
  24.  
  25.  
  26.             public string[] FileNamesFromFolder<T>(string folderpath) where T : UnityEngine.Object {
  27.                 var allfiles = Resources.LoadAll<T>(folderpath);
  28.                 return allfiles.Select(obj => obj.name).ToArray();
  29.             }
  30.  
  31.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top