Bark UI offset not working

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Dex
Posts: 3
Joined: Thu Jul 07, 2022 12:53 pm

Bark UI offset not working

Post by Dex »

Hello, changing the bark UI offset in the dialogue actor doesn't actually affect the position of the bark UI. Working in 2D, bark canvas set to screen space - overlay.
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bark UI offset not working

Post by Tony Li »

Hi,

The Dialogue Actor's offset should still apply, but the bubble bark prefab also has an internal offset on its Main Panel GameObject. If you're using the bubble bark prefab, you can duplicate it, set the Main Panel's Y Pos to 0, and assign the duplicate to the Dialogue Actor (either as a prefab or a child). (I'd do this to the original prefab, but many existing games use the bark UI as-is, so I don't want to impact the positions in their games.)
Dex
Posts: 3
Joined: Thu Jul 07, 2022 12:53 pm

Re: Bark UI offset not working

Post by Dex »

Hello, thank you for the reply. I was using the Standard Bark UI, but have the same problem when trying with the Bubble UI. The offset works in World Space, but not in Screen Space for me.
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bark UI offset not working

Post by Tony Li »

Sorry, I forgot you said screen space. If you have an offset of 2, the offset will only move 2 pixels. Instead, use this script:

UIFollow.cs

Code: Select all

using UnityEngine;
public class UIFollow : MonoBehaviour
{
    [SerializeField] private Transform followThis;
    [SerializeField] private RectTransform container;
    [SerializeField] private RectTransform ui;
    [SerializeField] private Vector3 offset;

    private void LateUpdate()
    {
        var screenPoint = RectTransformUtility.WorldToScreenPoint(Camera.main, followThis.position + offset);
        Vector2 localPoint;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(container, screenPoint, null, out localPoint);
        ui.anchoredPosition = localPoint;
    }
}

1. Remove the Always Face Camera component. (This only applies to world space.)

2. UNtick the StandardBarkUI component's Keep In View checkbox. (This only applies to world space.)

3. Set the child panel's Pivot to 0.5, 0.5

4. Add UIFollow it to your bark UI's child panel. Set the fields to:
  • Follow This: Main GameObject (e.g., NPC)
  • Container: bark UI
  • UI: child panel
  • Offset: Offset in world units (e.g., 0,2,0)
Dex
Posts: 3
Joined: Thu Jul 07, 2022 12:53 pm

Re: Bark UI offset not working

Post by Dex »

That worked, thank you!
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bark UI offset not working

Post by Tony Li »

Glad to help!
Post Reply