- Home /
wrong localScale on instantiated object unity
I have a prefab called "element" and it has a re-sizing scale script on it.
function Start () {
var width = sr.sprite.bounds.size.x;
var height = sr.sprite.bounds.size.y;
var worldScreenHeight = Camera.main.orthographicSize * 2.0;
var worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;
transform.localScale.x = worldScreenHeight / height;
transform.localScale.y = worldScreenHeight / height;
}
This object is being instantiated by another object.
Instantiate(element1, Vector3(lastPosition,0,0), Quaternion.Euler(0,0,0));
Debug.Log((element1.transform.localScale.x));
But when I try to debug its localScale, it shows "1" and not the actual number which is "1.07"(even though this no is shown in the inspector panel). What is happening here?
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Unity Scaling an object from scripts 1 Answer
Preventing Rapid Fire 2 Answers
Values are changing but the scale of sprite no. 1 Answer
Colliders with JS only 2 Answers