I have multiple scenes that use different assets (prefabs) downloaded from the internet. In a few of the scenes im working on, I want to programmatically change the scale of these prefabs at runtime. In the editor, I set them as a child of a empty game object with scale (1,1,1). The scaling looks and feels fine even programmatically at runtime. But then back in the editor i make some adjustments and modify some seemingly unrelated things (materials, positions of game objects, etc.) and all of a sudden the programmatic scaling breaks. Some things in the prefab scale normally and other things in the SAME prefab dont. But the editor scaling is perfectly normal - the children scale as they should. Im a noob so I think im overlooking something obvious. What in the world is happening?
Heres some logs. Both balls are in the prefab which is a child of sceneRoot. ball looks as if it scales normally (changing size and position), but ball2 looks to be the exact same size and in the exact same position as it was before. But it IS scaling properly based on the logs, right?
public void OnScaleSliderChanged()
{
sceneRoot.transform.localScale = new Vector3(scaleSlider.value, scaleSlider.value, scaleSlider.value);
Debug.Log("sceneRoot Position: " + sceneRoot.transform.position);
Debug.Log("sceneRoot local Scale: " + sceneRoot.transform.localScale);
Debug.Log("sceneRoot lossy Scale: " + sceneRoot.transform.lossyScale);
Debug.Log("ball Position: " + ball.transform.position);
Debug.Log("ball local Scale: " + ball.transform.localScale);
Debug.Log("ball lossy Scale: " + ball.transform.lossyScale);
Debug.Log("ball2 Position: " + coloredBall.transform.position);
Debug.Log("ball2 local Scale: " + coloredBall.transform.localScale);
Debug.Log("ball2 lossy Scale: " + coloredBall.transform.lossyScale);
}
sceneRoot Position: (38.30, 0.39, -91.60)
sceneRoot local Scale: (1.04, 1.04, 1.04)
sceneRoot lossy Scale: (1.04, 1.04, 1.04)
ball Position: (14.68, 11.74, -76.07)
ball local Scale: (6.73, 6.73, 6.73)
ball lossy Scale: (7.01, 7.01, 7.01)
ball2 Position: (35.90, -0.02, -73.90)
ball2 local Scale: (1.00, 1.00, 1.00)
ball2 lossy Scale: (1.24, 1.17, 1.46)
sceneRoot Position: (38.30, 0.39, -91.60)
sceneRoot local Scale: (2.01, 2.01, 2.01)
sceneRoot lossy Scale: (2.01, 2.01, 2.01)
ball Position: (-7.24, 22.26, -61.67)
ball local Scale: (6.73, 6.73, 6.73)
ball lossy Scale: (13.51, 13.51, 13.51)
ball2 Position: (33.67, -0.39, -57.49)
ball2 local Scale: (1.00, 1.00, 1.00)
ball2 lossy Scale: (2.38, 2.26, 2.82)