- Home /
Retreive the Width Delta of a ContentSizeFitter game object
Here is a screenshot of my project organisation. My List Container
object is a basic RectTransform of width 1000. My object List Grid
contains a Content Size Fitter
component, using "Horizontal Fit : Preferred Size".
When my project is run, I would like to retreive the value for the W Delta
field (in this case, -170). So far, I've tried displaying the following data, using the Debug.Log() method from the List Grid
game object :
-
GetComponent(RectTransform).rect.width
displays "1000"
-
GetComponent(RectTransform).sizeDelta
displays "(0.0, 0.0)"
-
GetComponent(RectTransform).rect.size
displays "(1000.0, 570.0)"
-
GetComponent(RectTransform).rect.xMax
displays "1000"
In all cases, the value displayed is either 0 or the width of my List Container
. What is the correct way to retrieve the W Delta
field ?