---
tags:
    - "Dialogue"
    - "Script"
    - "Play"
    - "Start"
    - "Begin"
---

# Play Dialogue

Game Creator / Dialogue / **Play Dialogue**

## Description

Starts playing a Dialogue component with an optional UI skin

## Parameters

| Name | Description |
| :--- | :---------- |
| Dialogue | The Dialogue to play |
| Skin | The Skin to use bound to the Dialogue component |
| Await | Determines if the instruction waits till the Dialogue is finished |

## Code

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

namespace GameCreator.Runtime.Dialogue
{
    [Title("Play Dialogue")]
    [Image(typeof(IconDialogue), ColorTheme.Type.Blue)]

    [Description("Starts playing a Dialogue component with an optional UI skin")]
    [Category("Game Creator/Dialogue/Play Dialogue")]

    [Parameter("Dialogue", "The Dialogue to play")]
    [Parameter("Skin", "The Skin to use bound to the Dialogue component")]
    [Parameter("Await", "Determines if the instruction waits till the Dialogue is finished")]

    [Keywords("Dialogue", "Script", "Play", "Start", "Begin")]

    [Serializable]
    public class InstructionDialoguePlay : Instruction
    {
        [SerializeField] private GetGameObject m_Dialogue = new GetGameObject(
            new TypeGameObjectDialogue()
        );

        [SerializeField] private GetScriptableObject m_Skin = new GetScriptableObject(
            new TypeScriptableObjectDialogueSkin()
        );

        [SerializeField] private GetBool m_Await = new GetBool(false);

        protected override string GetTitle(GameObject source) => $"Play {this.m_Dialogue} with {this.m_Skin}";

        protected override async Awaitable Run(Args args)
        {
            Dialogue dialogue = this.m_Dialogue.Get<Dialogue>(args);
            if (dialogue == null) return;

            DialogueSkin skin = this.m_Skin.Get<DialogueSkin>(args);
            Awaitable awaitable = dialogue.Play(args.Target, skin);

            if (this.m_Await.Get(args)) await awaitable;
            else awaitable.Fire(null, dialogue);
        }
    }
}
```

