Exemple #1
0
    void DrawGuiRightSide()
    {
        int ypos        = 50;
        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;
            }
        }
        else
        {
            if (GUI.Button(new Rect(Screen.width - (buttonWidth + 20), ypos, buttonWidth, 30), "Play custom AudioClip"))
            {
                AudioController.Play("CustomAudioItem");
            }

            if (wasClipAdded)
            {
                ypos += yposOff;

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

        ypos = 130;

#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 = new PoolableReference <AudioObject>(AudioController.Play("IntroLoopOutro_Gun"));
        }

        ypos += 20;
        ypos += yposOff;

        BeginDisabledGroup(!(introLoopOutroAudio != null && introLoopOutroAudio.Get() != null));

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

        EndDisabledGroup();

#if !UNITY_AUDIO_FEATURES_4_1
        EndDisabledGroup();
#endif
    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoolableReference&lt;T&gt;"/> class from
 /// a given <see cref="PoolableReference&lt;T&gt;"/>.
 /// </summary>
 /// <param name="poolableReference">The poolable reference.</param>
 public PoolableReference(PoolableReference <T> poolableReference)
 {
     _objComponent      = poolableReference._objComponent;
     _pooledObj         = poolableReference._pooledObj;
     _initialUsageCount = poolableReference._initialUsageCount;
 }
    void DrawGuiRightSide()
    {
        int ypos = 50;
        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;
            }
        }
        else
        {
            if ( GUI.Button( new Rect( Screen.width - ( buttonWidth + 20 ), ypos, buttonWidth, 30 ), "Play custom AudioClip" ) )
            {
                AudioController.Play( "CustomAudioItem" );
            }

            if ( wasClipAdded )
            {

                ypos += yposOff;

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

        ypos = 130;

#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 [Unity v4.1]" ) )
        {
            AudioController.Play( "GaplessLoopTest" ).Stop( 1, 4 );
        }
        ypos += yposOff;

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

        if ( GUI.Button( new Rect( Screen.width - ( buttonWidth + 20 ), ypos, buttonWidth, 50 ), "Play intro-loop-outro sequence\ngatling gun [Unity v4.1]" ) )
        {
            introLoopOutroAudio = new PoolableReference<AudioObject>( AudioController.Play( "IntroLoopOutro_Gun" ) );
        }

        ypos += 20;
        ypos += yposOff;

        BeginDisabledGroup( !(introLoopOutroAudio != null && introLoopOutroAudio.Get() != null) );

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

        EndDisabledGroup();

#if !UNITY_AUDIO_FEATURES_4_1
        EndDisabledGroup();
#endif

    }