forked from XINCGer/UnityToolchainsTrick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSceneViewExtension.cs
45 lines (42 loc) · 1.52 KB
/
SceneViewExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace ToolKits
{
public class SceneViewExtension
{
private static float RotateSpeed = 0.1f;
[InitializeOnLoadMethod]
public static void EditorInitialize()
{
SceneView.duringSceneGui -= Update;
if (EditorPrefs.GetBool(Constants.SCENE_VIEW_EXTENSITON_SWITH, false))
{
SceneView.duringSceneGui += Update;
}
}
private static void Update(SceneView sceneView)
{
var e = Event.current;
if (null != e)
{
var isFPS = Tools.viewTool == ViewTool.FPS;
if (isFPS && e.keyCode == KeyCode.F)
{
//左旋
var lastAngle = SceneView.lastActiveSceneView.rotation.eulerAngles;
var newAngle = new Vector3(lastAngle.x,lastAngle.y,lastAngle.z - RotateSpeed);
SceneView.lastActiveSceneView.rotation = Quaternion.Euler(newAngle);
}
else if (isFPS && e.keyCode == KeyCode.G)
{
//右旋
var lastAngle = SceneView.lastActiveSceneView.rotation.eulerAngles;
var newAngle = new Vector3(lastAngle.x,lastAngle.y,lastAngle.z + RotateSpeed);
SceneView.lastActiveSceneView.rotation = Quaternion.Euler(newAngle);
}
}
}
}
}