Edit quest dialogue

(jm) #1

please help me if someone knows about it.

(Leslie Young) #2

This can be a bit complicated. I’ll show you some untested code to give an idea of how I would approach this.

// probably easiest to modify the sample UI's script.
// you will probably have something like this at the top of the script to link the UI Image elements with
UnityEngine.UI.Image[] questIconUI = new UnityEngine.UI.Image[3];

then UpdateDialoguePanel() might be modified to something like this.

public void UpdateDialoguePanel()
	// get the waiting node. I will cast it to Dialogue Node type since that is
	// only "waiting type" node that this code supports. So if it was not correct
	// type then the dialogue panel will close.
	DiaQNode_Dlg node = DiaQEngine.Instance.graphManager.NodeWaitingForData() as DiaQNode_Dlg;

	if (node != null)
		// first hide all the quest icons since they might not be used for this node
		for (int i = 0; i < questIconUI.Length; i++)

		// check if this Node has a linked to a Quest
		object questIDObj = node.GetMetaDataValue("QuestID");
		DiaQuest quest = questIDObj == null ? null : DiaQEngine.Instance.questManager.GetQuestById((int)questIDObj);
		// get the reward icons if there is a linked quest
		if (quest != null)
			int uiIdx = 0;
			for (int i = 0; i < quest.rewards.Count; i++)
				// get the sprite. skip if none found, else set a UI element
				Sprite sp = quest.rewards[i].GetMetaDataValue("icon") as Sprite;
				if (sp != null)
					questIconUI[uiIdx].sprite = sp;

You will note there are two types of meta being used here. The 1st asks the dialogue node if it is linked to a quest. That is done by adding the meta QuestID (an Integer) to a node. If it is not present then it is assumed that Node is not related to a Quest. The quest Id, 0, I found by looking at the ID in the inspector of the Quest.

Now each reward in the quest must be given a Sprite icon. Add meta for each with the name icon (a UnityObject type) and drop a sprite object into each.

(jm) #4

it didn’t work. this is all i need for my project :frowning:

(Idcrisis Arito) #5

If this is all I needed for my project I’d sleep well at night. :slight_smile:

You could just set a temp var of the reward and get the info inside blox.

(jm) #6

can you show me how? please!

(Leslie Young) #7

Did you get errors?.. Show what you did?..

(jm) #8

@leslie i am confused about this.

do i need to replace this code

 if (node != null)
			// update panel with correct text
			UnityEngine.UI.Text dialogueText = dialoguePanel.transform.FindChild("Text").GetComponent<UnityEngine.UI.Text>();
			dialogueText.text = node.ParsedDialogueText(true);

			// update buttons (there are 3 buttons)
			for (int responseIdx = 0; responseIdx < 3; responseIdx++)
				string buttonObjectName = "Button " + (responseIdx + 1).ToString(); // "Button 1", "Button 2", "Button 3" ...
				Transform button = dialoguePanel.transform.FindChild(buttonObjectName);

				// check if the node has this many responses and show/ hide button depending on result
				if (node.responses.Length > responseIdx)
					// show button and update its text
					button.GetChild(0).GetComponent<UnityEngine.UI.Text>().text = node.ParsedResponseText(responseIdx);
					// else hide the button as there is no response text to show on it

with the one you gave?

(Leslie Young) #9

Just insert it where it seems to fit in. Do not remove code. I showed from the start of the function so that you can see where it fits in after the IF statement but before the rest of the code in that IF.

Honestly, if you are not capable of making this level of changes you probably should not. It is easy to break something. Like I mentioned, I have not tested this code but it should given a capable programmer a good starting point on ideas to apply if it does not work outright.

(jm) #10

alright, later im gonna show you what i did, please help me if i did something wrong