Version: 5.5

Handles.PositionHandle

Switch to Manual
public static Vector3 PositionHandle (Vector3 position, Quaternion rotation);

Parameters

position @param position Центр маркера в 3D пространстве.
rotation @param position Центр маркера в 3D пространстве.

Returns

Vector3 The new 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.

Description

Делает 3D маркер для позиции в окне Scene

This behaves like the built-in Move tool in Unity.

Для управления ориентацией маркера, установите в Handles.matrix приоритет на вызов этой функции.




Важно: Используйте HandleUtility.GetHandleSize если вам нужны маркеры постоянного размера.

To use this example, save this script to the Assets/Editor folder:

using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(PositionHandle))] public class PositionHandleEditor : Editor { void OnSceneGUI() { PositionHandle t = target as PositionHandle;

// Set the colour of the next handle to be drawn Handles.color = Color.magenta;

EditorGUI.BeginChangeCheck(); Vector3 lookTarget = Handles.PositionHandle(t.lookTarget, Quaternion.identity);

if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Changed Look Target"); t.lookTarget = lookTarget; t.Update(); } } }

Then, place this script on the GameObject you want to edit the LookAt point for:

using UnityEngine;

[ExecuteInEditMode] public class PositionHandle : MonoBehaviour { public Vector3 lookTarget = new Vector3(0, 2, 0);

public void Update() { // Make the object always face the position handle transform.LookAt(lookTarget); } }