Version: 2023.2
언어: 한국어

ReserveModifiersAttributeConstructor

매뉴얼로 전환
public ReserveModifiersAttribute (ShortcutManagement.ShortcutModifiers modifiers);

파라미터

modifiers One or more modifiers to reserve.

설명

Creates an attribute that reserves a modifier for a single shortcut.

using UnityEditor;
using UnityEditor.ShortcutManagement;
using UnityEngine;

public class CustomSceneViewNavigation : ScriptableSingleton<CustomSceneViewNavigation> { bool moveForward; bool moveBack; bool boost;

[ClutchShortcut("Custom Scene Navigation/Move Forward", KeyCode.KeypadMinus)] [ReserveModifiers(ShortcutModifiers.Shift)] static void MoveForward(ShortcutArguments args) { instance.moveForward = args.stage == ShortcutStage.Begin; }

[ClutchShortcut("Custom Scene Navigation/Move Back", KeyCode.KeypadPlus)] [ReserveModifiers(ShortcutModifiers.Shift)] static void MoveBack(ShortcutArguments args) { instance.moveBack = args.stage == ShortcutStage.Begin; }

private void OnEnable() { SceneView.duringSceneGui += DuringSceneGUI; }

private void OnDisable() { SceneView.duringSceneGui -= DuringSceneGUI; }

void DuringSceneGUI(SceneView view) { boost = Event.current.shift;

var speed = boost ? 5 : 1; var direction = Vector3.zero;

if (moveForward) direction += view.camera.transform.forward;

if (moveBack) direction += -view.camera.transform.forward;

view.pivot += direction.normalized * Time.smoothDeltaTime * speed; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961