示例#1
0
    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();
        }
    }
示例#2
0
        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;
            }
        }
示例#3
0
    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();
        }
    }
示例#4
0
    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();
        }
    }
示例#5
0
    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");
    }
示例#6
0
    static void CreateMusicSystem()
    {
        GATEditorUtilities.CheckManager();

        EditorWindow.GetWindowWithRect <MusicSystemWizard>(new Rect(300f, 300f, 300f, 120f), true, "Music System Wizard");
    }
示例#7
0
    static void CreatePulsedSamples()
    {
        GATEditorUtilities.CheckManager();

        GATEditorUtilities.NewChildGO <PulsedPatternModule>("Pulsed Pattern");
    }
示例#8
0
    static void CreateSubPulse()
    {
        GATEditorUtilities.CheckManager();

        GATEditorUtilities.NewChildGO <SubPulseModule>("Sub Pulse");
    }
示例#9
0
    static void CreateMasterPulse()
    {
        GATEditorUtilities.CheckManager();

        GATEditorUtilities.NewChildGO <MasterPulseModule>("Master Pulse");
    }
示例#10
0
    static void CreateEnvelope()
    {
        GATEditorUtilities.CheckManager();

        GATEditorUtilities.NewChildGO <EnvelopeModule>("Envelope");
    }