Hello
So i’m in trouble with something. I need to add an script on a object from another script. So i tried to use AddComponent.
function Update () {
img.transform.SetParent(GameObject.FindObjectOfType(Canvas).gameObject.transform, false);
img.gameObject.AddComponent(UI.RawImage);
img.gameObject.GetComponent(UI.Shadow).effectDistance=Vector2(10,-10);
img.gameObject.GetComponent(UI.RawImage).texture=BoxInfo1;
img.gameObject.AddComponent("SuppresionBoxUI");
}
The problem is that unity don’t add error. And when i try to play the game, it said that i must fix errors first.
I made somes test and conclude that it’s the last line who got some problem.
So is there a way to add a script in runtime or is there a way to fix that.
Thank you for reading this
3T3A