在设置父节点方法内加入false
transform.SetParent(parent, false);
transform.SetParent(parent, false);
就是不跟随父节点比例
public void SetParent(Transform parent, bool worldPositionStays);
Parameters
parent | The parent Transform to use. |
worldPositionStays | If true, the parent-relative position, scale and rotation is modified such that the object keeps the same world space position, rotation and scale as before. |
Description
Set the parent of the transform.
This method is the same as the parent property except that it's possible to make the Transform keep its local orientation rather than its global orientation by setting the worldPositionStays parameter to false.
官方API文档:http://docs.unity3d.com/ScriptReference/Transform.SetParent.html