Resize Rect Transform via code

Here is my code:

private void ResizeVertically(float height)
    {
        //_panelRectTransform.anchorMin.Set(0, height);      
        //_panelRectTransform.rect.Set(10, 10, 10, 10);
        _panelRectTransform.sizeDelta.Set(0, height);       
    }

I have checked that _panelRectTransform is being set at Start() using the following code:

_panelRectTransform = this.GetComponent<RectTransform>();

When I run a GetType on _panelRectTransform after this, it is returning a Rect Transform object.

Here are the Inspector settings for the Rect Transform:

When I try to resize via code there seems to be no effect whatsoever. Anyone have any tips?

sizeDelta is a struct property. In C#, you can’t modify struct properties inside. You have to assign it to a temporary variable, modify it, and then assign it back. It’s very annoying, but there’s little we can do to change the language unfortunately.