Dialog and Objective View Tut Gif

 Survival Shooter Link:

Unity Version:

  • Unity 2018.1.5f1



  • Talking to the player. Giving them information. (In-Game Information)
  • Player Tutorials.
  • NPC Giving objectives/quests to a player.
  • Simple quest system
  • A conversation between two or more characters.


To follow along, the Dialog Box Tutorial, and the Objective View Tutorial need to be finished first. The goal of this tutorial is simple. We want to use the DialogBox to deliver a message to the player. At the end of the message, the player accepts the request, and is added to the playerObjectiveController. The same way it’s implemented in the Objective View Tutorial.


In our Project’s Panel, we will add a few more scripts

  • Demo/Scripts/ObjectiveView/Events/OnObjectiveDialogCall.cs
  • Demo/Scripts/ObjectiveView/ObjectiveEvent.cs

Manipulating our Code…

In the DialogBox Tutorial, we created a way to Initialize our DialogBox by feeding Content to our DialogBox via:

  • DialogBox.Initialize(content);

This was a good way to feed it our new content piece whenever we needed to use the DialogBox. However, if we want to tie a request to the end of the conversation, we need to add a few updates to the DialogBox.Initialize piece.


Let’s start with our ObjectiveEvent.cs class. We need a way to tie in our Content with our Requests to the DialogBox. We can do this easily by adding a reference to both our Content object, and Request object.

public class ObjectiveEvent : MonoBehaviour
   public Content contentForEvent;
   public Request request;

   public virtual void BeginEvent()

We also added a BeginEvent() method. This will be used by our DialogBox, after the player has gone through all of the dialog content, and is ready to Start the request. If you want to manipulate it further, but want to keep the base implementation, the virtual method allows you to derive from this class, and manipulate it further.

  • NOTE: Since both Content, and Request Objects are serialized from the previous tutorials, this makes them ready to go in the inspector, to allow the Game Developer, to manipulate it freely in the inspector.

Updating our DialogBox.cs

Now, we need to add a few more fields to the DialogBox.cs class.






A Reference to our playerObjectiveController.



Invoked when the dialogBox is first triggered.



Invoked on the final page of the dialogBox.

The UnityEvents allow you to add custom features you may want to use at the start of your dialogBox. The confirmationTrigger however, will be cleared, of any events.

Now we need to make a second Initialize Method that accepts a different kind of parameter. The new method will be :
  • DialogBox.Initialize(ObjectiveEvent);

We need to feed our objective event to the dialogBox, and Start the Request when the player has finished reading the Dialog Text. We can do that by triggering the confirmationTrigger on the last page.

public void Initialize(ObjectiveEvent objectiveEvent)
   if(confirmationTrigger != null)

   if(objectiveEvent != null)
      dialogContent = objectiveEvent.contentForEvent;
      confirmationTrigger.AddListener(() =>

   if(startingDialogTrigger != null)

   displayText.text = dialogContent.InitialContent();
  • In the Initialize Method, we first Activate the DialogObject, and RemoveAllListeners() from the confirmationTrigger. The purpose is to remove any previous confirmationTriggers that existed.
  • Next we check for the objectiveEvent, and assign the content in the event, to our dialogContent.
  • Afterwords we assign a new listener to our confirmationTrigger. We need to add our request from our objectiveEvent to the objective Controller:
    • objectiveController.AddNewRequest(objectiveEvent.request);
  • Then we initiate any event functions from the ObjectiveEvent.
    • objectiveEvent.BeginEvent();
  • Finally we added a startingDialogTrigger. We won’t be going much further with this, in this tutorial, but if we wanted to invoke any other features, such as sound effects, or events whenever the dialogbox is open, we can add it to the startingDialogTrigger UnityEvent.


Now we can Initialize our DialogBox any which way, but personally, am a big fan of Events, so We’re going to make our own UnityEvent, and use this in our StartObjective class.

public class OnObjectiveDialogCall : UnityEvent { }

We just need a way to invoke our DialogBox and feed it our Request.

We can do that by creating a CharacterStart.cs class, and adding our OnObjectiveDialogCall to the class.


public class CharacterStart : MonoBehaviour

   //The location where the player first spawns at.
   private Transform spawnLocation;

   // The player reference.
   public GameObject playerReference;

   // Invoked after reaching the starting location. 
   // Typically used for cutscenees, or invoking the tutorial. 
   public OnObjectiveDialogCall onObjectiveDialogCall; 

   private ObjectiveEvent objectiveEvent; 

   public void Start() 
      spawnLocation = this.transform; 
      playerReference.transform.position = spawnLocation.transform.position; 
      objectiveEvent = this.gameObject.GetComponent(); 
      if(onObjectiveDialogCall != null) 

When the game starts, we get our spawnLocation, and have our player move to the spawnLocation.

Then we get our objectiveEvent component, and invoke it to our DialogBox.

In the inspector, we assign our DialogBox, and Initialize the object:


We also assign our ObjectiveEvent Component:


This is implemented the same way, and method we implemented our DynamicObjectiveView Tutorial. We just added a few pieces to it.

In our Content, we fill it with elements we want our DialogBox to say.
and in the Request, we simply make it accessible, and put our DisplayText that we want in the objective.
Down in the OnRequestBegin, we start our Destination object, and feed our RequestId that will be given to our destination object.
also, in the OnRequestComplete, we disable our Destination object once the request has been finished.

Destination Object:

Inspector - EndObjective

A reference to our PlayerObjectiveController is added to our CompleteObjective script.

The only other important thing to note, is to deactivate the destination object, and have the Request.OnStartRequest activate it when the request begins.

Happy Developing!