I am making a game which has text that is read from an xml file and every round it changes. I have a box collider 2d on the text, but I am trying to make it so that the collider is no longer than the text that has been read. Is this possible to do in c#?
sure, it’s possible. You can dynamically disable the GameObject with the collider by using
GameObject.SetActive(bool) or just destroy it
Destroy(GameObject)if you don’t need it anymore.
CurrentBoxCollider.size = new Vector3(mydata,mydata2,mydata3);
//above code is manipulating the collider manually(u calculate the new size)
//But in my last project according to my experiences
//Whenever you add a collider to a Gameobject via script the collider
//Will fit perfectly
//So just destroy the rpev collider and add a new to it
//Sciprt is not copy pasta! just an example