Answer the question
In order to leave comments, you need to log in
How to store GetComponent in a variable?
Hello, I have the following code:
void Start()
{
SomeType SomeName = gameObject.GetComponent<RectTransform>().anchoredPosition;
SomeName = new Vector2(x, y);
}
Answer the question
In order to leave comments, you need to log in
Save not anchoredPosition to variable, but RectTransform itself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question