I’m trying to make an editorscript that detects which files are selected in the Project-window and populate them in an array or list, when creating a GameObject. I have the following code:
[MenuItem("GameObject/Custom/AudioClipShuffler")]
static void CreateAudioClipShuffler()
{
GameObject go = new GameObject("AudioClipShuffler");
AudioClipShuffler audioClipShuffler = go.AddComponent<AudioClipShuffler>();
// Get whatever is selected in the Project-window as an array or list
// Filter down to only an array or list of AudioClips (called audioClips)
audioClipShuffler.SetAudioClips(audioClips); //SetAudioClips takes an array or list
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
(inspired by Unity - Scripting API: MenuItem)
Can anyone please help me with the two steps I’m missing? Thanks so much in advance!