@@ -13,84 +13,84 @@ namespace UTJ.UnityEditor.Extension.SceneViewFovControl {
13
13
static class SceneViewHiddenApiExtension {
14
14
const BindingFlags nonPublicInstance = BindingFlags . NonPublic | BindingFlags . Instance ;
15
15
16
- static readonly Type typeSceneView = typeof ( global ::UnityEditor . SceneView ) ;
16
+ static readonly Type typeSceneView = typeof ( global ::UnityEditor . SceneView ) ;
17
17
static readonly MethodInfo mi_UseSceneFiltering = typeSceneView . GetMethod ( "UseSceneFiltering" , nonPublicInstance ) ;
18
18
static readonly MethodInfo mi_SceneCameraRendersIntoRT = typeSceneView . GetMethod ( "SceneCameraRendersIntoRT" , nonPublicInstance ) ;
19
- static readonly FieldInfo fi_m_GizmosContent = typeSceneView . GetField ( "m_GizmosContent" , nonPublicInstance ) ;
20
- static readonly FieldInfo fi_m_RenderDocContent = typeSceneView . GetField ( "m_RenderDocContent" , nonPublicInstance ) ;
19
+ static readonly FieldInfo fi_m_GizmosContent = typeSceneView . GetField ( "m_GizmosContent" , nonPublicInstance ) ;
20
+ static readonly FieldInfo fi_m_RenderDocContent = typeSceneView . GetField ( "m_RenderDocContent" , nonPublicInstance ) ;
21
21
22
22
public static bool UseSceneFiltering ( this SceneView sceneView ) {
23
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1033
23
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1033
24
24
return ( bool ) mi_UseSceneFiltering . Invoke ( sceneView , null ) ;
25
25
}
26
26
27
27
public static bool SceneCameraRendersIntoRT ( this SceneView sceneView ) {
28
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1200
28
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1200
29
29
return ( bool ) mi_SceneCameraRendersIntoRT . Invoke ( sceneView , null ) ;
30
30
}
31
31
32
- public static GUIContent Get_m_GizmosContent ( this SceneView sceneView ) {
33
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L215
34
- return fi_m_GizmosContent . GetValue ( sceneView ) as GUIContent ;
35
- }
32
+ public static GUIContent Get_m_GizmosContent ( this SceneView sceneView ) {
33
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L215
34
+ return fi_m_GizmosContent . GetValue ( sceneView ) as GUIContent ;
35
+ }
36
36
37
- public static GUIContent Get_m_RenderDocContent ( this SceneView sceneView ) {
38
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L219
39
- return fi_m_RenderDocContent . GetValue ( sceneView ) as GUIContent ;
40
- }
37
+ public static GUIContent Get_m_RenderDocContent ( this SceneView sceneView ) {
38
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L219
39
+ return fi_m_RenderDocContent . GetValue ( sceneView ) as GUIContent ;
40
+ }
41
41
42
- static Rect [ ] PopGUIClips ( this SceneView sceneView ) {
43
- int count = 1 ;
44
- if ( ! sceneView . UseSceneFiltering ( ) && sceneView . SceneCameraRendersIntoRT ( ) ) {
45
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1255
46
- ++ count ;
47
- }
48
- Rect [ ] guiClips = new Rect [ count ] ;
49
- for ( int i = 0 ; i < count ; ++ i ) {
50
- guiClips [ i ] = GUIClip . GetTopRect ( ) ;
51
- GUIClip . Pop ( ) ;
52
- }
53
- return guiClips ;
42
+ static Rect [ ] PopGUIClips ( this SceneView sceneView ) {
43
+ int count = 1 ;
44
+ if ( ! sceneView . UseSceneFiltering ( ) && sceneView . SceneCameraRendersIntoRT ( ) ) {
45
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L1255
46
+ ++ count ;
47
+ }
48
+ var guiClips = new Rect [ count ] ;
49
+ for ( int i = 0 ; i < count ; ++ i ) {
50
+ guiClips [ i ] = GUIClip . GetTopRect ( ) ;
51
+ GUIClip . Pop ( ) ;
52
+ }
53
+ return guiClips ;
54
54
}
55
55
56
- static void PushGUIClips ( this SceneView sceneView , Rect [ ] guiClips ) {
57
- for ( int i = guiClips . Length - 1 ; i >= 0 ; -- i ) {
56
+ static void PushGUIClips ( this SceneView sceneView , Rect [ ] guiClips ) {
57
+ for ( int i = guiClips . Length - 1 ; i >= 0 ; -- i ) {
58
58
GUIClip . Push ( guiClips [ i ] , Vector2 . zero , Vector2 . zero , false ) ;
59
- }
59
+ }
60
60
}
61
61
62
62
const float LeftMargin = 251f ;
63
63
const float TopOffset = - 1f ;
64
64
const float MinGuiContentWidth = 16f ;
65
- const float RightOffset = 300.0f ;
65
+ const float RightOffset = 300.0f ;
66
66
67
- // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L810
68
- //
69
- // If we can put the following function after above ^ line, there's no problem.
70
- // But since we don't have any hook in the toolbar, the following function emulates it.
71
- // note : This code doesn't coexistent with other user toolbar extensions such as "Scene View Bookmarks" [1]
72
- //
73
- // [1] Scene View Bookmarks https://www.assetstore.unity3d.com/en/#!/content/22302
74
- public static void DoToolbarRightSideGUI ( this SceneView sceneView , GUIContent content , GUIStyle style , Action < Rect > action ) {
67
+ // https://github.com/MattRix/UnityDecompiled/blob/753fde37d331b2100f93cc5f9eb343f1dcff5eee/UnityEditor/UnityEditor/SceneView.cs#L810
68
+ //
69
+ // If we can put the following function after above ^ line, there's no problem.
70
+ // But since we don't have any hook in the toolbar, the following function emulates it.
71
+ // note : This code doesn't coexistent with other user toolbar extensions such as "Scene View Bookmarks" [1]
72
+ //
73
+ // [1] Scene View Bookmarks https://www.assetstore.unity3d.com/en/#!/content/22302
74
+ public static void DoToolbarRightSideGUI ( this SceneView sceneView , GUIContent content , GUIStyle style , Action < Rect > action ) {
75
75
Vector2 size = style . CalcSize ( content ) ;
76
- float wb = sceneView . position . width - RightOffset ;
77
- float lx = wb - size . x ;
78
- if ( lx < LeftMargin ) {
79
- lx = LeftMargin ;
80
- size . x = wb - lx ;
81
- }
82
- if ( size . x > MinGuiContentWidth ) {
83
- var rect = new Rect ( lx , TopOffset , size . x , size . y ) ;
84
- var active = RenderTexture . active ;
85
- RenderTexture . active = null ;
86
- Rect [ ] guiClips = sceneView . PopGUIClips ( ) ;
76
+ float wb = sceneView . position . width - RightOffset ;
77
+ float lx = wb - size . x ;
78
+ if ( lx < LeftMargin ) {
79
+ lx = LeftMargin ;
80
+ size . x = wb - lx ;
81
+ }
82
+ if ( size . x > MinGuiContentWidth ) {
83
+ var rect = new Rect ( lx , TopOffset , size . x , size . y ) ;
84
+ var active = RenderTexture . active ;
85
+ RenderTexture . active = null ;
86
+ Rect [ ] guiClips = sceneView . PopGUIClips ( ) ;
87
87
88
- action ( rect ) ;
88
+ action ( rect ) ;
89
89
90
- sceneView . PushGUIClips ( guiClips ) ;
91
- RenderTexture . active = active ;
92
- }
93
- }
90
+ sceneView . PushGUIClips ( guiClips ) ;
91
+ RenderTexture . active = active ;
92
+ }
93
+ }
94
94
}
95
95
96
96
}
0 commit comments