Automatically Select First Quest in Quest Log Window
Posted: Sun Apr 12, 2020 6:53 am
Hi,
I'm working on integrating the standard Quest Log UI into my project, and I'm having a bit of an issue regarding my control scheme- My game works on a keyboard only, and I want to automatically select the first quest in the main quest window. To do this I added a new script to to the Quest Titles Content game object here:
My script is:
Since the new quests are instantiated underneath Completed Quest Heading Template, I set startIndexNumber to 3 (4th child). However, on doing this I get an index out of range error on launching the game (expected, since there would not be a quest on game start yet), on first opening the log window (regardless of there being a quest in there or not), and then finally I get a print on 2nd opening onwards, but the button does not select, nor do I get the no button print.
Do you know why this is the case?
Sorry if this is not a Dialogue System question- I think it might be more of a general Unity thing.
I'm working on integrating the standard Quest Log UI into my project, and I'm having a bit of an issue regarding my control scheme- My game works on a keyboard only, and I want to automatically select the first quest in the main quest window. To do this I added a new script to to the Quest Titles Content game object here:
My script is:
Code: Select all
Button button;
public int startIndexNumber; // number to start list check from
// Start is called before the first frame update
private void OnEnable()
{
print(transform.GetChild(startIndexNumber));
if (transform.GetChild(startIndexNumber) != null)
{
button = transform.GetChild(startIndexNumber).GetComponent<Button>();
button.Select();
}
else
{
print("no button in the index number");
}
}
Do you know why this is the case?
Sorry if this is not a Dialogue System question- I think it might be more of a general Unity thing.