void OnGUI() { bool canCreate = false; EditorGUIUtility.fieldWidth = 70f; EditorGUIUtility.labelWidth = 80f; _sampleBank = ( GATActiveSampleBank )EditorGUILayout.ObjectField("Sample Bank:", _sampleBank, typeof(GATSampleBank), true); if (_sampleBank != null) { if (_sampleBank.SoundBank == null) { EditorGUILayout.HelpBox("Your SampleBank must refer to a SoundBank!", MessageType.Error); } else { canCreate = true; } } else { EditorGUILayout.HelpBox("Creating a Music System is a shortcut to create and link a MasterPulse, an Envelope, and a Pattern. Creating a Music System requires a SampleBank object in your scene.", MessageType.Info); } GUI.enabled = canCreate; GUI.color = Color.green; if (GUILayout.Button("Create", GUILayout.ExpandWidth(false))) { MasterPulseModule pulse = GATEditorUtilities.NewChildGO <MasterPulseModule>("Music System"); EnvelopeModule envelope = GATEditorUtilities.NewChildGO <EnvelopeModule>("Envelope", pulse.gameObject); envelope.Pulse = pulse; envelope.MaxSamples = _sampleBank.SoundBank.SizeOfShortestSample(); PulsedPatternModule pattern = GATEditorUtilities.NewChildGO <PulsedPatternModule>("Pattern", pulse.gameObject); pattern.Envelope = envelope; pattern.SampleBank = _sampleBank; pattern.Pulse = pulse; pattern.AddSample(_sampleBank.SoundBank.SampleInfos[0].Name); this.Close(); } }
public ImportInfo(AudioClip clip) { Clip = clip; Path = AssetDatabase.GetAssetPath(clip.GetInstanceID()); GUID = AssetDatabase.AssetPathToGUID(Path); Importer = AssetImporter.GetAtPath(Path) as AudioImporter; if (GATEditorUtilities.IsInResources(Path)) { PathInResources = GATEditorUtilities.PathInResources(Path); } else if (GATEditorUtilities.IsInStreamingAssets(Path)) { PathInResources = GATEditorUtilities.PathInStreamingAssets(Path); System.IO.Path.ChangeExtension(PathInResources, System.IO.Path.GetExtension(Importer.assetPath)); IsStreamingAsset = true; } }
void OnGUI() { EditorGUIUtility.fieldWidth = 150f; EditorGUIUtility.labelWidth = 80f; _soundBank = ( GATSoundBank )EditorGUILayout.ObjectField("Sound Bank: ", _soundBank, typeof(GATSoundBank), false, GUILayout.ExpandWidth(false)); if (_soundBank == false) { EditorGUILayout.HelpBox(__soundBankHelp, MessageType.Info); GUI.enabled = false; } else { _bankType = ( BankType )EditorGUILayout.EnumPopup("Bank Type: ", _bankType, GUILayout.ExpandWidth(false)); EditorGUILayout.HelpBox(__bankTypesHelp[( int )_bankType], MessageType.Info); } GUI.color = Color.green; if (GUILayout.Button("Create", GUILayout.Width(70f))) { GATEditorUtilities.CheckManager(); GATSampleBank bank = null; switch (_bankType) { case BankType.Simple: bank = GATEditorUtilities.NewChildGO <GATSampleBank>("Sample Bank"); break; case BankType.Active: bank = GATEditorUtilities.NewChildGO <GATActiveSampleBank>("Sample Bank"); break; } bank.EditorUpdateSoundBank(_soundBank); this.Close(); } }
void OnGUI() { EditorGUIUtility.fieldWidth = 60f; EditorGUIUtility.labelWidth = 80f; _sampleRate = ( SampleRates )EditorGUILayout.EnumPopup("Sample Rate:", _sampleRate, GUILayout.ExpandWidth(false)); GUILayout.Space(10f); GUI.color = Color.green; if (GUILayout.Button("Create", GUILayout.Width(70f))) { GATSoundBank soundBank = GATEditorUtilities.CreateAsset <GATSoundBank>("New SoundBank"); switch (_sampleRate) { case SampleRates._24000: soundBank.Init(24000); break; case SampleRates._44100: soundBank.Init(44100); break; case SampleRates._48000: soundBank.Init(48000); break; case SampleRates._88200: soundBank.Init(88200); break; case SampleRates._96000: soundBank.Init(96000); break; } this.Close(); } }
public void CheckBankIntegrity(List <GATSampleInfo> sampleInfos) { if (Application.isPlaying) { throw new GATException("Check integrity cannot be called in play mode!"); } string path; string pathInResources; AudioClip clip; bool bankHasErrors = false; List <GATSampleInfo> samplesToRemove = new List <GATSampleInfo>(); foreach (GATSampleInfo info in sampleInfos) { path = AssetDatabase.GUIDToAssetPath(info.GUID); if (path == "") { info.clipStatus = SoundBankClipStatus.NotFound; if (ClipNotFoundDialog(info.Name)) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } clip = ( AudioClip )AssetDatabase.LoadAssetAtPath(path, typeof(AudioClip)); if (clip == null) { info.clipStatus = SoundBankClipStatus.NotFound; if (ClipNotFoundDialog(info.Name)) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } pathInResources = GATEditorUtilities.PathInResources(path); if (pathInResources == null) { pathInResources = GATEditorUtilities.PathInStreamingAssets(path); } if (pathInResources == null) { info.clipStatus = SoundBankClipStatus.NotInResources; if (EditorUtility.DisplayDialog("AudioClip not in Resources", string.Format("clip {0} was found, but is not in a Resources or StreamingAssets folder. Remove it from the SoundBank?", info.Name), "Remove", "Skip")) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } else if (pathInResources != info.PathInResources) { info.clipStatus = SoundBankClipStatus.Moved; Debug.Log(string.Format("moved form {0} to {1}", info.PathInResources, pathInResources)); if (EditorUtility.DisplayDialog("AudioClip moved", string.Format("clip {0} was found but has moved since it was added to the SoundBank. Update path info?", info.Name), "Update", "Skip")) { info.UpdatePathInResources(); } else { bankHasErrors = true; } continue; } } foreach (GATSampleInfo info in samplesToRemove) { _soundBank.RemoveSample(info); } EditorUtility.SetDirty(_soundBank); string endDialog = bankHasErrors ? "This Sound Bank contains errors that need to be fixed before it is loaded." : "No errors!"; EditorUtility.DisplayDialog("Check Completed", endDialog, "OK"); }
static void CreateMusicSystem() { GATEditorUtilities.CheckManager(); EditorWindow.GetWindowWithRect <MusicSystemWizard>(new Rect(300f, 300f, 300f, 120f), true, "Music System Wizard"); }
static void CreatePulsedSamples() { GATEditorUtilities.CheckManager(); GATEditorUtilities.NewChildGO <PulsedPatternModule>("Pulsed Pattern"); }
static void CreateSubPulse() { GATEditorUtilities.CheckManager(); GATEditorUtilities.NewChildGO <SubPulseModule>("Sub Pulse"); }
static void CreateMasterPulse() { GATEditorUtilities.CheckManager(); GATEditorUtilities.NewChildGO <MasterPulseModule>("Master Pulse"); }
static void CreateEnvelope() { GATEditorUtilities.CheckManager(); GATEditorUtilities.NewChildGO <EnvelopeModule>("Envelope"); }