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:
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?