- Home /
Changing localPosition gives no error, but doesnt change prefab localPosition
I am instantiating a prefab, and guiElements are positioned from child objects to this prefab. When i put this in the prefab script:
void Start() { transform.localPosition = Vector3.zero; }
It never changes in game. I look at the prefab in the hierarchy at runtime and the prefab is still at some odd random coordinates (obviously messing up locations of gui textures). Why doesn't this prefab instance change?
I also tried using:
Instantiate(myPrefab,Vector3.zero,new Quaternion(0,0,0,0) );
But this didnt work either to change the position. My position isnt changed elsewhere in my code.
Is the object parented to something else? What happens if you set:
transform.position = Vector3.zero; ?
Are you looking at the prefab, or the instance? Remember that prefabs are static- 'Start' never actually gets called on them.
Your answer
Follow this Question
Related Questions
GameObject position and localPosition not changing in hiearchy, only in script. 0 Answers
How use local position of prefab for my instantiate ? 1 Answer
Instantiate Object At Local Position 2 Answers
Changing LocalScale in code affecting prefab stored in Assets 1 Answer
Instantiate a prefab vs create one dynamically at runtime? 1 Answer