- Home /
Question by
minkaren1 · Mar 24, 2019 at 08:04 AM ·
gameobjectprefabmateriallocalscale
When setting a local scale to an instantiated gameObject, it loses material.
Hi guys, 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;
}
[2]: /storage/temp/135231-снимок.png
снимок.png
(2.3 kB)
снимок2.png
(3.7 kB)
Comment
Changing the scale has nothing to do with the material. There has got to be something else going on. What else are you doing with the gameobject reference you return un that method and are you using the standard shader?