Can I set RectTransform parameters with object initializers

Hello !

I’m trying to get a better way to initialize my components. Using object initializers, I thought I could do :

		var inputTextRect = inputText.GetComponent<RectTransform>();
		var inputPlaceholderRect = inputPlaceholder.GetComponent<RectTransform>();

		inputTextRect = inputPlaceholderRect = new RectTransform {
			anchorMin = dd.GetVector2(0f,0f),
			anchorMax = dd.GetVector2(1f,1f),
			offsetMin = dd.GetVector2(10f,6f),
			offsetMax = dd.GetVector2(-10f,-7f)
		};

… but I can’t :

Console :
NullReferenceException
UnityEngine.RectTransform.set_anchorMin (Vector2 value)

What am I doing wrong ?

Thanks for your help !

Im not sure what dd is but if it is NullException, I’m betting that dd is not initialized.