ue3dUnity的变换工具

Unity的变换工具

分类:
ue3d - Unity的变换工具

本文3D天堂将详细介绍转换工具,将会看到如何使用转换工具和脚本更改游戏对象的转换, 以下是本文介绍的几个内容:

变换工具

变换工具用于移动、旋转、缩放或矩形变换场景中选定的游戏对象,转换工具位于Unity界面工具栏部分的最左侧。

ue3d - Unity的变换工具

手工具

ue3d - Unity的变换工具

Hand工具不用于更改游戏对象的变换,它仅用于场景的左右上下移动导航。

如下所示

ue3d - Unity的变换工具

移动工具

默认情况下,会在unity软件中选择移动转换。

ue3d - Unity的变换工具

使用此工具更改游戏对象的位置,最后更改的轴将以黄色显示。

如下所示

ue3d - Unity的变换工具

旋转工具

ue3d - Unity的变换工具

使用旋转工具改变游戏对象的旋转角度,最后更改的轴将以黄色显示。

如下所示

ue3d - Unity的变换工具

缩放工具

ue3d - Unity的变换工具


使用缩放工具更改游戏对象的大小,最后更改的轴将以黄色显示。

如下所示

ue3d - Unity的变换工具

矩形变换

ue3d - Unity的变换工具

矩形变换主要用于定位UI元素或2D元素,但也可以使用此工具操作3D对象,可以使用此工具更改游戏对象的比例。

如下所示

ue3d - Unity的变换工具

在变换工具之间切换的键盘快捷键

使用下面给定的热键在转换工具之间切换

  • Q → 手动工具
  • W → 移动
  • E → 旋转
  • R → 缩放
  • T → 矩形变换

在运行时更改游戏对象的变换

获取GameObject的变换组件并使用脚本更改其位置、旋转和缩放。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TransformDemo : MonoBehaviour {

	// Use this for initialization
	void Start () {
		// change position of the GameObject
		Debug.Log("Previous Position: " + GetComponent<Transform> ().position);
		GetComponent<Transform> ().position = new Vector3 (2.0f, 0.0f, 0.0f);
		Debug.Log("New Position: " + GetComponent<Transform> ().position);

		// change rotation of the GameObject using Euler Angle
		Debug.Log("Previous Rotation: " + GetComponent<Transform> ().eulerAngles);
		GetComponent<Transform> ().eulerAngles = new Vector3 (90.0f, 0.0f, 0.0f);
		Debug.Log("New Rotation: " + GetComponent<Transform> ().eulerAngles);

		// Change scale of of the GameObject
		Debug.Log("Previous Scale: " + GetComponent<Transform> ().localScale);
		GetComponent<Transform> ().localScale = new Vector3 (2.0f, 2.0f, 2.0f);
		Debug.Log("New Scale: " + GetComponent<Transform> ().localScale);
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

在控制台显示的结果

ue3d - Unity的变换工具

以上是3D天堂关于学习Unity中的转换工具的全部内容,如果你有任何反馈,请随时在本页面下方留言。

相关信息

  • 类型:知识
  • 字数:424
  • 字符:2028
  • 适用软件:Unity
  • 说明:无
  • 编号:156244

热门内容

提示:3D天堂作为服务提供者,尊重网络版权及知识产权,对某些行为的发生不具备充分的监控能力,若无意间侵犯到您的权利,请 联系我们,我们会在收到信息后尽快给予处理。

本站文章版权归本站自创作者所有,未经允许不得转载!