Esempio n. 1
0
    void DrawGuiRightSide()
    {
        int ypos        = 10;
        int yposOff     = 35;
        int buttonWidth = 300;

        if (!wasCategoryAdded)
        {
            if (customAudioClip != null && GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Create new category with custom AudioClip"))
            {
                var category = AudioController.NewCategory("Custom Category");
                AudioController.AddToCategory(category, customAudioClip, "CustomAudioItem");
                wasClipAdded     = true;
                wasCategoryAdded = true;
            }
            ypos += yposOff;
        }
        else
        {
            if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Play custom AudioClip"))
            {
                AudioController.Play("CustomAudioItem");
            }

            ypos += yposOff;

            if (wasClipAdded)
            {
                if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Remove custom AudioClip"))
                {
                    if (AudioController.RemoveAudioItem("CustomAudioItem"))
                    {
                        wasClipAdded = false;
                    }
                }
            }
        }

        ypos += yposOff;

#if !UNITY_AUDIO_FEATURES_4_1
        BeginDisabledGroup(true);
#endif

        if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Play gapless audio loop"))
        {
            AudioController.Play("GaplessLoopTest").Stop(1, 4);
        }
        ypos += yposOff;

        if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Play random loop sequence"))
        {
            AudioController.Play("RandomLoopSequence");
        }
        ypos += yposOff;

        if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 50), "Play intro-loop-outro sequence\ngatling gun"))
        {
            introLoopOutroAudio = AudioController.Play("IntroLoopOutro_Gun");
        }

        ypos += 20;
        ypos += yposOff;

        BeginDisabledGroup(introLoopOutroAudio == null);

        if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Finish gatling gun sequence"))
        {
            introLoopOutroAudio.FinishSequence();
        }

        EndDisabledGroup();
        ypos += yposOff;

#if !UNITY_AUDIO_FEATURES_4_1
        EndDisabledGroup();
#endif

        ypos += 10;

        const float textWidth = 500;

        GUI.skin.box.alignment = TextAnchor.UpperLeft;
        GUI.skin.box.wordWrap  = true;
        GUI.skin.box.richText  = true;

        const string infoText =
            "<size=18><color=orange>Welcome to Audio Toolkit!\n</color></size>" +
            "<size=14>The number one audio management solution for Unity used in AAA titles!\n\n" +
            "What does the toolkit do? In a nutshell:\n" +
            "1) It separates scripting from managing audio:\n" +
            " Let your audio artist define complex behaviours of what 'MySoundID' will sound like. All within the Unity inspector.\n" +
            "2) Trigger audio without any scripting knowledge using the example behaviours like <color=lightblue>PlayAudio</color> or by script with\n" +
            " a simple function call, e.g. <color=lightblue>AudioController.Play( \"MySoundID\" );</color>\n" +
            "3) It makes life much easier in many ways: control volume by categories, play random effects, chain sequences of sound files, define sound alternatives, manage playlists, ...\n" +
            "\n<color=cyan>Select the AudioController game object to see how to configure audio in the inspector!</color>" +
            "</size>";

        GUI.Box(new Rect(Screen.width - textWidth, ypos, textWidth - 10, Screen.height - ypos - 60), infoText);
    }