public static Vector3 ScaleHandle (Vector3 scale, Vector3 position, Quaternion rotation, float size);

Parameters

scale要修改的缩放。
position手柄的位置。
rotation手柄的旋转。
size允许您在屏幕上缩放手柄的大小。

Returns

Vector3 通过用户与手柄的交互修改的新值。如果用户没有移动手柄,则将返回您传递给相应函数的值。

Description

创建一个场景视图缩放手柄。

此手柄的行为类似于内置缩放工具

注意:如果您希望拥有恒定屏幕大小的手柄,请使用 HandleUtility.GetHandleSize


Scale handle that will appear whenever you select the GameObject.

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

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

EditorGUI.BeginChangeCheck(); Vector3 scale = Handles.ScaleHandle(t.scale, Vector3.zero, Quaternion.identity, 1); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Scaled ScaleAt Point"); t.scale = scale; t.Update(); } } }

附加到此游戏对象的脚本:

// Name this script "ScaleAtPoint"
using UnityEngine;
[ExecuteInEditMode]
public class ScaleAtPoint : MonoBehaviour
{
    public Vector3 scale = Vector3.one;
    public void Update()
    {
        transform.localScale = scale;
    }
}