I'm instantiating a gameObject from prefab, and I want to set local scale using code, but when I'm setting transform.localScale to the gameObject then it loses material and becomes black.
public GameObject ballObject;
public GameObject GetBall(Ball ball)
{
GameObject gameObject = Instantiate(ballObject, ball.position, Quaternion.identity);
gameObject.transform.localScale = ball.scale; // actually, this line destroys the material
gameObject.tag = Constants.ballTag;
return gameObject;
}