Use Utage for Conversation Scenes


Utage is used not only for visual novels, but also for creating conversation scenes in games and tutorials.
Here we provide a summary on how to do this.


Add a Scenario Playback Engine to an Existing Scene

Create a new project from Tools > Utage > New Project.


Enter a project name, and set ‘Type’ to ‘Add To Current Scene.’

In LayerSetting, you will need to set a Utage layer that is independent from the layers of existing scenes. You can use the default values of Utage and UtageUI without any problems, but you can also set any layer names as you wish.
Configure GameScreenSize to specify the expected screen size for the game you are going to create. Smartphones and other similar devices have completely different resolutions, so the screens are displayed by zooming in and out based on this size as the standard.

Press the Create button to add the GameObjects that are necessary for playing back scenarios in existing scenes, as well as the scenario Excel files and assets.
In addition, with Utage 2.4.0 or earlier, after creating the project you will need to Manually configure cameras and layers.

Up to here is the preparation stage.

Call Utage from a Game

Call scenarios based on whatever timing you like depending on each game.

サンプルコード


using UnityEngine;
using System.Collections;
using Utage;
public class TalkArea : MonoBehaviour {

    public AdvEngine engine;
    public string scenarioLabel;

    // コリジョンにぶつかった
    void OnCollisionEnter()
    {
        StartCoroutine( CoTalk() );
    }

    IEnumerator CoTalk()
    {
        //Utageのシナリオを呼び出す
        engine.JumpScenario( scenarioLabel );

        //Utageのシナリオ終了待ち
        while(!engine.IsEndScenario)
        {
            yield return 0;
        }
    }
}

The AdvEngine starts executing a scenario from the moment that you pass a scenario label to JumpScenario().
It then uses IsEndScenario to wait for the scenario to finish executing. This means that it will wait until the EndScenario command is called, so please make sure to write EndScenario as a delimiter for the conversation scenes.

Scenario example:
2014-06-11_10h39_44
EndScenario is used as the delimiter of a conversation section.

Link with the Game while Leaving Utage’s Display on Screen

When you use EndScenario, all Utage displays are terminated as well, causing the characters, etc. to become hidden.
To leave the display on screen as it is, use the PauseScenario command.
This should be useful for creating tutorials, etc.

Scenario example:

In this way, you can determine Utage’s pause status from the game.

サンプルコード


using UnityEngine;
using System.Collections;
using Utage;
public class PauseSample : MonoBehaviour {
 
	AdvEngine Engine { get { return engine ?? (engine = FindObjectOfType<AdvEngine>()); } }
	public AdvEngine engine;
	 
    // 会話開始
    void OnStartTalk(string scenarioLabel)
    {
        StartCoroutine( CoTalk(scenarioLabel) );
    }
 
    IEnumerator CoTalk(string scenarioLabel)
    {
        //Utageのシナリオを呼び出す
        engine.JumpScenario( scenarioLabel );
 
        //Utageのポーズ終了待ち
        while(!engine.IsPausingScenario)
        {
            yield return 0;
        }

		//ゲームの再開処理を書く
		//???????

		//Utageを再開するのはResumeScenarioで
		//別シーンを呼び出すなら、改めてJumpScenarioしても良い
		engine.ResumeScenario();
    }
}