Unity3d transform
2016-07-19 21:58
393 查看
using UnityEngine; using System.Collections; public class transform : MonoBehaviour { // Use this for initialization void Start () { //获取当前脚本所挂载的游戏对象身上的Transform //控制游戏对象的位置、选择、缩放 Vector3 pos = transform.position;//世界坐标位置 print(pos); Vector3 local_pos = transform.localPosition; print(local_pos); //一般不直接修改四元数 //transform.rotation; //transform.localRotation; //localScale:控制游戏对象的缩放 Vector3 vScale = transform.localScale; //控制游戏对象间的父子关系 Transform parent = transform.parent; //当前游戏对象的根对象 Transform root = transform.root; //获取当前游戏对象的子对象Cube Transform child_ = transform.Find("Cube"); Transform child = transform.FindChild("Cube"); } // Update is called once per frame void Update () { if(Input.GetKeyDown(KeyCode.P)) { //transform.position = Vector3.zero; //transform.localScale = new Vector3(1f, 2f, 1f); //改变当前游戏对象位置 //transform.Translate(new Vector3(1f, 0, 0)); //控制当前游戏对象旋转 //transform.Rotate(Vector3.up, 10f);//以Vector3.up位轴心旋转10度 transform.eulerAngles = new Vector3(0, 45, 0); } } }
相关文章推荐
- 简单总结Unity使用Resources类资源管理
- 【Unity】Unity下载器下载不下IOS/Android等模块的解决办法
- unity平台相关宏
- [置顶] 【shaderToy】中openGL转到unity中的一些技巧
- Unity UGGUI RawImage 渲染小地图
- unity3d meshBaker 基本的使用
- Unity开发篇(1)
- HoloLens开发手记 - Unity development overview 使用Unity开发概述
- unity游戏在安卓按home或者锁屏键后不能后台运行的结局方案
- unity调android ios 浏览器 uniwebview2.1使用
- 京城游戏人-Day6:Unity 点击坐标与世界坐标
- 【Unity】关于Unity切换手机前后相机
- Unity3d爬坑记—'physicMaterial' is not a member of 'UnityEngine.TerrainData'. 报错!!
- Unity UGUI —— 无限循环List(转载)
- 简单总结Unity使用AssetDatabase编辑器资源管理
- PlayerPrefs存储数据在本地的存储位置
- Unity快速实现回合制游戏
- unity语言本地化插件 I2 Location2.5.6使用简单记录
- unity3d之VS2013默认编辑器问题
- 由Unity5.3.3f1引发的一场血案