GameObject gameObj = new GameObject(); BoxCollider2D box = gameObj.AddComponent<BoxCollider2D>() as BoxCollider2D; gameObj.AddComponent<Text1Script>();