Unity 2018 Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

To create a one-sentence dialog using Fungus, follow these steps:

  1. Create a new Unity 2D project.
  2. Open the Asset Store panel, search for Fungus, and Import this free asset package (search for Fungus and free).
  3. Create a new Fungus Flowchart GameObject by choosing menu: Tools | Fungus | Create | Flowchart.
  4. Display and dock the Fungus Flowchart window panel by choosing menu: Tools | Fungus | Flowchart Window.
  5. There will be one block in the Flowchart Window. Click on this block to select it (a green border appears around the block to indicate that it is selected). In the Inspector panel, change the Block Name of this block to Start:

  1. Each Block in a Flowchart follows a sequence of commands. So in the Inspector, we are now going to create a sequence of (Say) commands to display two sentences to the user when the game runs.
  2. Ensure that the Start block is still selected in the Flowchart panel. Click on the plus (+) button at the bottom section of the Inspector panel to display the menu of Commands, and select the Narrative | Say command:

  1. Since we only have one command for this block, that command will automatically be selected (highlighted green) in the top part of the Inspector. The bottom half of the Inspector presents the properties for the currently-selected Command, as shown in the following screenshot. In the bottom half of the Inspector, for the Story Text property, enter the text of the question that you wish to be presented to the user, which is How are you today?:

  1. Create another Say Command, and type the following for its Story Text property: Very well thank you.
  2. When you run the game, the user will first be presented with the How are you today? text (hearing a clicking noise as each letter is typed on screen). After the user clicks on the continue triangle button (at the bottom-right part of the dialog window), they will be presented with the second sentence: Very well thank you.