dialog on second object is partial. Why?
Code:
int diagIndex = 0;
int sizeofDialouge = 0;
npcControl npcProp = interObj.GetComponent<npcControl>(); // this retrieves a script from the object
nameTxt.text = npcProp.namez; // this is the name property of the object.
diagTxt.text = npcProp.diaglist[diagIndex]; // this sets a dialog window to the first element contained in the list of dialog within the dialog list
sizeofDialouge = npcProp.diaglist.Count;
// display
dialougeContainer.SetActive(true);
// increment dialouge
continueBtn.onClick.AddListener(delegate {
Debug.Log(sizeofDialouge);
if (diagIndex < sizeofDialouge - 1) // if current index is less than total, show dialouge
{
diagIndex++;
diagTxt.text = npcProp.diaglist[diagIndex];
}
else // if current index exceeds the last index of list, then disable and reset everything
{
dialougeContainer.SetActive(false);
diagIndex = 0;
}
});
Script below contains the dialog info.
public class npcControl : MonoBehaviour
{
public string namez = "Bob";
public List<string> diaglist = new List<string>();
}
[1] has size 3 (diaglist: x, y, z)
[2] has size 4 (diaglist: a,b,c,d)
At start of game, clicking on [1] object reports Count correctly as 3. Then clicking on [2], reports Count as 3 and 4 (it should only show 4). The [1] object works fine and the dialog window shows x,y,z. [2] object shows a,b,c but not d.
unitypic.jpg
(4.3 kB)
Comment
Your answer
Follow this Question
Related Questions
Encyclopedia System 1 Answer
Best Practice For Storing RPG Dialogue? 1 Answer
How to show dialogue when triggered by collision with npc collide box? 0 Answers
RPG Dialogue? 2 Answers
Errors, Errors, and more Errors? 2 Answers