unity变换游戏对象

代码:

    public GameObject cube;
    public GameObject cylinder;
    void OnGUI()
    {
        if(GUILayout.Button("向左移动物体"))
        {
            cube.transform.Translate( new Vector3(-0.5f,0f,0f));
        }
        if(GUILayout.Button("向右移动物体"))
        {
            cube.transform.position = cube.transform.position + new Vector3(0.5f,0f,0f);
        }
        if(GUILayout.Button("放大物体"))
        {
            cube.transform.localScale *= 1.2f;
        }
        if(GUILayout.Button("缩小物体"))
        {
            cube.transform.localScale *= 0.8f;
        }
        if(GUILayout.Button("旋转物体"))
        {
            cube.transform.Rotate(new Vector3(0,10,0));
        }
        if(GUILayout.Button("围绕圆柱体旋转物体"))
        {
            cube.transform.RotateAround(cylinder.transform.position,Vector3.up,10);
        }
    }

 

posted @ 2017-12-15 08:45  easydots  阅读(467)  评论(0编辑  收藏  举报