GUI.StackPanel _measureForChildren seems to return incorrect value

Open console to see it returning width: 861, and height: 80 – The ratio of which is way off from what is on the screen.

And attempting to upgrade my app to v4 seems to show sameish results, all my stack panel menus are stretched too wide

Well. First, every property that starts with underscore like that one is a private property. And you should not use them ever. In the ideal world we should not see them at all as available, at least I believe that’s the case (I think that only recently, or will soon implemented in javascript new ways of creating a private variables that will not be seen, I think I heard about that on this years Google I/O).

So with that said, I have no idea why that doesn’t work. But you should probably use something like this. (lines 52-55)

Maybe there is more elegant way but maybe that can help you.


Yes I am well aware of the “dangers” of using private properties. In the ideal world, maybe, in the real world, when working with a library as large and complex as Babylon, there are plenty of scenarios where it makes more sense to use what is there than reinvent the wheel or overcomplicate things. – There are already ways to do that, i.e. symbols (or a function outside of the class), but using them is only going to make code harder to debug and worst of all, more obfuscated.

One of the difficulties in using undocumented _ properties is knowing exactly what they are returning. It seems that as the heights are set in pixels, the height for children is set to the pixel height of the stack panel and as the widths are given as a fraction the width for children is set to the canvas width as you can see from this