Instantiate - Prefab as Child

Hello everyone…

Quick question:

ParentObject.cs

_childObject = Instantiate(Resources.Load(_childObjectPath)) as GameObject;
_childObject.transform.parent = this.transform;
Debug.Log (_childObject.transform.position);

I get this in the dbg:

(0.0, -0.2, 0.0)
UnityEngine.Debug:Log(Object)

But I check on my hierarchy to see if the childObject is actually child of the parentObject.(It is…) but to my surprise the position that appears on the inspector is different to the one that it debugged.

To be precise…

(5.7,-0.2,1)

The one the debugger gives me is the correct position(which I gave to the prefab when I created it…).

Why is it changing?

Thanks for your help and time.

The coordinates in the Inspector are probably relative to the parent object.
Try Debug.Log(_childObject.transform.localPosition); and see if that matches your expected values or switch coordinate space in unity between local/global.