Version: 5.5
public static Quaternion RotationHandle (Quaternion rotation, Vector3 position);

パラメーター

rotation ハンドルの向き
position 3D 空間でのハンドルの中心

戻り値

Quaternion The new rotation value modified by the user's interaction with the handle. If the user has not moved the handle, it returns the same value that you passed into the function.

説明

シーンビューの Rotation ハンドルを作ります。

Unity のビルトインにある Rotation ツールのように動作します。Undo.SetSnapshotTarget に何かを指定することによって Undo を実装することができます。


Rotate the attached object from the Rotation Handle.

注意: 画面サイズに対して固定サイズのハンドルを持ちたい場合、HandleUtility.GetHandleSize を使用します。

// Name this script "RotateAtPointEditor"
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(RotateAtPoint))] [CanEditMultipleObjects] public class RotateAtPointEditor : Editor { public void OnSceneGUI() { RotateAtPoint t = (target as RotateAtPoint);

EditorGUI.BeginChangeCheck(); Quaternion rot = Handles.RotationHandle(t.rot, Vector3.zero); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Rotated RotateAt Point"); t.rot = rot; t.Update(); } } }

このスクリプトをゲームオブジェクトに置きます。

// Name this script "RotateAtPoint"
using UnityEngine;

[ExecuteInEditMode] public class RotateAtPoint : MonoBehaviour { public Quaternion rot = Quaternion.identity; public void Update() { transform.rotation = rot; } }