0 votes

I'm working on a tool for my game where I can visualize charts.

To visualize the charts I use a Line2D in a container so that I can control the layout better.
My current layout looks like this:

PanelContainer (scene root)

To ensure all points in Line2D fit inside the width of the ReferenceRect I calculate the x position for the points as follows:

for (int i = 0; i < points.Length; i++)
  var x = i * (chartWidth / points.Length)

I had hoped that I could get chartWidth by accessing the size of the parent ReferenceRect: chartWidth = parentReferenceRect.RectSize.x.
This works fine in the scene itself.

However, when I create an instance of the chart editor in a container in another scene it no longer works:

enter image description here

Layout in other scene:

Node2d (scene root)
    ChartEditor scene instance

Even though the size of the ReferenceRect is increased, the RectSize property has not been changed. Is there a way for me to get the actual size at runtime instead of relying on whatever size is set in the editor?

Godot version v.3.2.3.stable.mono.official
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.