Page 2 of 2

Re: Bubble button arrangement

Posted: Fri May 22, 2020 2:40 pm
by joeylu
Sorry Tony, I thought it was working but actually it was because of the old implementation wasn't deleted :(
I'm actually having a problem with the subclass

here's what I wrote and i added it to the Bubble Template Standard UI Menu Panel game object

Code: Select all

public class OxenfreeUIMenuPanel : StandardUIMenuPanel {
  public override void Awake() {
    base.Awake();
    Debug.Log("awake");
  }
  public override void ShowResponses(Subtitle subtitle, Response[] responses, Transform target) {
    base.ShowResponses(subtitle, responses, target);
    Debug.Log("ShowResponses");
  }
}
I disabled the original StandardUIMenuPanel script

The result is.. only the awake debug message is shown, when my menu dialogue entry pops up, the ShowResponses doesn't return its debug message, any idea? tks

Re: Bubble button arrangement

Posted: Fri May 22, 2020 4:22 pm
by Tony Li
Hi,

Replace the StandardUIMenuPanel component with your custom script. Don't just disable StandardUIMenuPanel and add the other. To replace it:

1. Inspect the menu panel.
2. In the Inspector, use the menu in the upper right to change to Debug mode.
3. Draw your custom script from the Project folder into the StandardUIMenuPanel component's Script field.

This will replace the script while keeping all of the field assignments.

Finally, double check that your replacement script is assigned to the Dialogue Actor's custom menu panel field.

Re: Bubble button arrangement

Posted: Sat May 23, 2020 2:43 am
by joeylu
guess I just need to learn unity UI more, but Tony you again saves the day! Thank you

last question, in the ShowResponses() method, can I get the current menu entries position? So I can conditionally show/hide their related parent object
if not, or anywhere in the StandardUIMenuPanel subclass?

Re: Bubble button arrangement

Posted: Sat May 23, 2020 8:11 am
by Tony Li
The ShowResponses() method receives an array of Response objects. Each Response has a formattedText property with a position value.

If the response text has a [position=#] tag, the position value will be a specific index in the Buttons list.

If position is -1 (or the constant FormattedText.NoAssignedPosition if you prefer), it will automatically assign a position, using the first available button in the StandardUIMenuPanel's Buttons list. (Or the last available button if Button Alignment is set to To Last.)

For example, to show the positions of all responses that have [position=#] tags:

Code: Select all

for (int i = 0; i < responses.Length; i++)
{
    if (responses[i].formattedText.position == FormattedText.NoAssignedPosition)
    {
        Debug.Log("Response " + i + " will use first available button.");
    }
    else
    {
        Debug.Log("Response " + i + " will use button " + responses[i].formattedText.position);
    }
}
EDIT: Fixed typo.

Re: Bubble button arrangement

Posted: Sat May 23, 2020 2:57 pm
by joeylu
Hi Tony, do you mean responses.formattedText.position in your example? since the responses.position will throw out an error
anyway, it works and thank you :)

Re: Bubble button arrangement

Posted: Sat May 23, 2020 4:33 pm
by Tony Li
Yes. I'll fix my post above.