# Unload Scene Async

[Scenes](index.md) / **Unload Scene Async**

## Description

Unloads a scene asynchronously

## Parameters

| Name | Description |
| :--- | :---------- |
| Scene | The scene to unload |
| Await | Determines whether it awaits till the scene has been fully unloaded |

## Code

```cs
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Unload Scene Async")]
    [Image(typeof(IconUnity), ColorTheme.Type.TextLight, typeof(BadgeCross))]
    
    [Description("Unloads a scene asynchronously")]
    [Category("Scenes/Unload Scene Async")]
    
    [Parameter("Scene", "The scene to unload")]
    [Parameter("Await", "Determines whether it awaits till the scene has been fully unloaded")]
    
    [Serializable]
    public class InstructionCoreSceneUnloadAsync : Instruction
    {
        [SerializeField] private GetScene m_Scene = new GetScene();
        [SerializeField] private bool m_Await = true;

        protected override string GetTitle(GameObject source) => $"Unload async {this.m_Scene}";

        protected override async Awaitable Run(Args args)
        {
            int sceneIndex = this.m_Scene.Get(args);
            if (sceneIndex < 0) return;
            
            AsyncOperation asyncOperation = SceneManager.UnloadSceneAsync(sceneIndex);
            if (this.m_Await) await asyncOperation;
        }
    }
}
```

