找一个GameObjects Vector3

4 c# unity-game-engine unity5

最近我一直在研究保存/加载功能.我想要做的是Vector3在按下"保存"按钮后保存当前电流.但是,我似乎无法弄清楚如何找到一个GameObjects Vector3.

互联网上有很多教程,但它们都在JS中.

agc*_*nti 6

一个gameObjectVector3就是它transform.position.所以,如果您有参考,您可以使用:

Vector3 lastPosition = gameObject.transform.position;
Run Code Online (Sandbox Code Playgroud)

或者,如果保存脚本是gameObject自己的,您可以直接引用转换:

Vector3 lastPosition = transform.position;
Run Code Online (Sandbox Code Playgroud)

Unity Docs中的更多信息.