I have instantiated a sprite. I have set the sprite as a child of an empty game object ( PARENT ). PARENT has a width and height stored in RectTransform. How can I set the Sprite rect to match the PARENT rect ( I would like the sprite to have the same width and height as the parent object ).
Code
tCardDisplay = GameObject.Find("CardDisplay").transform;
tCardRowPos = GameObject.Find("CardRowPos").transform;
rectCardRowPos = GameObject.Find("CardRowPos").GetComponent<RectTransform>();
GameObject go = new GameObject();
Sprite sp = Instantiate(Resources.Load<Sprite>("card_blank_v000"),
new Vector3(0, 0, 0),
Quaternion.identity);
SpriteRenderer sr = go.AddComponent<SpriteRenderer>();
sr.sprite = sp;
This code loads the Sprite properly. The Sprite is used on multiple screens so I would like to resize it to suit the current screen ( whichever ). Upon Instantiation the Sprite is larger than the PARENT object. I am not sure how to resize the Sprite to match the PARENT object. Thanks for any replies.
,