Hi all,
my question is very simple : I would like to use the .Left (or .x) value of a GameObject => UI =>Image (the top left position of an image).
The problem is that the debugger does not find these values.
Thanks for your help.
A+
Hi all,
my question is very simple : I would like to use the .Left (or .x) value of a GameObject => UI =>Image (the top left position of an image).
The problem is that the debugger does not find these values.
Thanks for your help.
A+
Those values don’t actually exist. They’re a convenience for the RectTransform inspector.
You can get that information from the various properties of RectTransform such as:
Programmatically interacting with RectTransforms at the coordinate level is VERY difficult, fraught with all kinds of crazy dimensions and percentages and relationships, all dependent on how the canvas is set to scale.
You can see some of the computations they do in the source code for the UI package.
You can also see things like this massive blob of code, which is required simply to set anchors at the corners of a given RectTransform:
You can also use the RectTransformUtility class to help you, but it’s not well documented at all.