xenko
xenko copied to clipboard
UI Component non Billboard
Hi,
we created a scene where we have a TextBlock on the Ui-Component over each hexagon. We are not sure if desired or bug, but the drawn ui elements behave strangly: They start turning depending on camera rotation in a not desired way. See video & the code we used to draw the lables.
public class HexLabelScript : StartupScript
{
private UIComponent _ui;
private float UIScale = 2;
private TextBlock _labelTextBlock;
public string Text { set { _labelTextBlock.Text = value; } }
public override void Start()
{
base.Start();
SetupUiComponent();
SetupLabel();
}
private void SetupUiComponent()
{
_ui = Entity.GetOrCreate<UIComponent>();
_ui.VirtualResolution = new Vector3(60, 20, UIScale);
_ui.VirtualResolutionMode = VirtualResolutionMode.FixedWidthFixedHeight;
_ui.IsFullScreen = false;
_ui.IsBillboard = false;
}
private void SetupLabel()
{
_labelTextBlock = new TextBlock
{
Font = Content.Load<SpriteFont>("TextBoxFont"),
Text = UIScale.ToString(),
TextColor = Color.DodgerBlue,
//BackgroundColor = Color.Black,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
_ui.RootElement = _labelTextBlock;
}
}