内容参考Unity官方基础教程
操作系统:Win10
Unity版本:2019.4
Visual Studio版本:2019(Community)
详细API见Unity API
改变GameObject的Transform(Position/Rotation/Scale)
// 改变GameObject的Scale
transform.localScale += scaleChange;
// 改变GameObject的Position
transform.position += positionChange;
// 改变GameObject的Rotation
transform.Rotate(rotateChange);
代码中的scaleChange、positionChange、rotateChange的类型都是vector3
,且是公共变量,只有公共变量才能在显示在组件中。