Page 1 of 1
ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 8:15 am
by redisthecolor
Hi there,
I am currently customizing the response panel now and facing a bit of a problem.
So the response panel contains of button that fits the size of the text (so no max or min width / height)
In the editor, the spacing works well: it means if I duplicate the button several time and change the text inside, the space between button is the same.
But in the runtime I face the problem that the button has no space at all. And if I update the child alignment, then the spacing is correct. See the following gif: I even changed back to the original child alignment and the spacing is still correct.
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 9:29 am
by Tony Li
Hi,
There shouldn't be any difference in UI between editor and build, other than a different game view resolution. Test different Game view sizes to make sure the resolution isn't the issue. Keep in mind that when you play a build, it plays from the first scene in build settings. Make sure that scene, or whichever scene has the first instance of the Dialogue Manager GameObject, points to the right dialogue UI and not an older version.
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 5:49 pm
by redisthecolor
Just did a little digging. I am not the only one who has this problem. Probably not Dialoge Systems related. Since it has something to do with content size fitter that needs to be force updated
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 6:28 pm
by redisthecolor
So I created a script called ForceRebuildUI and add them to the ResponsePanel.
Code: Select all
public class ForceRebuildUI : MonoBehaviour
{
//Mark the given RectTransform as needing it's layout to be recalculated during the next layout pass.
public RectTransform rect;
private void Update()
{
LayoutRebuilder.MarkLayoutForRebuild(rect);
}
}
I have to put it in Update since it doesn't work inside OnEnable or Start. Do you think this is memory expensive? Or do you have better solution for me?
Thanks.
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 7:20 pm
by Tony Li
Hi,
That's going to affect performance. Try adding a script like this to the Dialogue Manager instead:
RebuildDialogueUI.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class RebuildDialogueUI : MonoBehaviour
{
void OnConversationResponseMenu(Response[] responses)
{
var rect = ((DialogueManager.dialogueUI as StandardDialogueUI).conversationUIElements.defaultMenuPanel.panel.GetComponent<RectTransform>())
LayoutRebuilder.MarkLayoutForRebuild(rect);
}
}
It will only issue the rebuild once when setting up each menu.
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 7:43 pm
by redisthecolor
Thanks. It works as well!
Re: ResponsePanel Spacing Problem/Bug?
Posted: Tue Dec 29, 2020 7:50 pm
by Tony Li
Glad to help!