|
9 | 9 | using UnityEngine.SceneManagement; |
10 | 10 | using RealtimeCSG.Helpers; |
11 | 11 |
|
| 12 | + |
12 | 13 | namespace RealtimeCSG |
13 | 14 | { |
14 | | - internal sealed class SceneViewEventHandler |
15 | | - { |
16 | | - static bool mousePressed; |
| 15 | + internal sealed class SceneViewEventHandler |
| 16 | + { |
| 17 | + static bool mousePressed; |
17 | 18 |
|
18 | 19 | static int prevFocusControl; |
19 | 20 |
|
20 | | - internal static void OnScene(SceneView sceneView) |
21 | | - { |
22 | | - CSGSettings.RegisterSceneView(sceneView); |
23 | | - if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG) |
24 | | - return; |
25 | | - |
26 | | - if (EditorApplication.isPlayingOrWillChangePlaymode) |
27 | | - return; |
28 | | - UpdateLoop.UpdateOnSceneChange(); |
29 | | - |
30 | | - if (!RealtimeCSG.CSGSettings.EnableRealtimeCSG) |
31 | | - ColorSettings.isInitialized = false; |
32 | | - else |
33 | | - if (!ColorSettings.isInitialized) |
34 | | - { |
35 | | - if (Event.current.type == EventType.Repaint) |
36 | | - { |
37 | | - ColorSettings.Update(); |
38 | | - } |
39 | | - } |
40 | | - |
41 | | - if (!UpdateLoop.IsActive()) |
42 | | - UpdateLoop.ResetUpdateRoutine(); |
43 | | - |
44 | | - if (Event.current.type == EventType.MouseDown || |
45 | | - Event.current.type == EventType.MouseDrag) { mousePressed = true; } |
46 | | - else if (Event.current.type == EventType.MouseUp || |
47 | | - Event.current.type == EventType.MouseMove) { mousePressed = false; } |
48 | | - |
49 | | - SceneDragToolManager.OnHandleDragAndDrop(sceneView); |
50 | | - RectangleSelectionManager.Update(sceneView); |
51 | | - EditModeManager.InitSceneGUI(sceneView); |
52 | | - |
53 | | - if (Event.current.type == EventType.Repaint) |
54 | | - MeshInstanceManager.UpdateHelperSurfaces(); |
55 | | - |
56 | | - if (Event.current.type == EventType.Repaint) |
57 | | - { |
58 | | - SceneToolRenderer.OnPaint(sceneView); |
59 | | - } else |
60 | | - //if (fallbackGUI) |
61 | | - { |
62 | | - SceneViewBottomBarGUI.ShowGUI(sceneView); |
| 21 | + internal static void OnScene( SceneView sceneView ) |
| 22 | + { |
| 23 | + CSGSettings.RegisterSceneView( sceneView ); |
| 24 | + |
| 25 | + if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG ) |
| 26 | + return; |
| 27 | + |
| 28 | + if( EditorApplication.isPlayingOrWillChangePlaymode ) |
| 29 | + return; |
| 30 | + |
| 31 | + UpdateLoop.UpdateOnSceneChange(); |
| 32 | + |
| 33 | + if( !RealtimeCSG.CSGSettings.EnableRealtimeCSG ) |
| 34 | + ColorSettings.isInitialized = false; |
| 35 | + else if( !ColorSettings.isInitialized ) |
| 36 | + { |
| 37 | + if( Event.current.type == EventType.Repaint ) |
| 38 | + { |
| 39 | + ColorSettings.Update(); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + if( !UpdateLoop.IsActive() ) |
| 44 | + UpdateLoop.ResetUpdateRoutine(); |
| 45 | + |
| 46 | + if( Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag ) |
| 47 | + { |
| 48 | + mousePressed = true; |
| 49 | + } |
| 50 | + else if( Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseMove ) |
| 51 | + { |
| 52 | + mousePressed = false; |
| 53 | + } |
| 54 | + |
| 55 | + SceneDragToolManager.OnHandleDragAndDrop( sceneView ); |
| 56 | + RectangleSelectionManager.Update( sceneView ); |
| 57 | + EditModeManager.InitSceneGUI( sceneView ); |
| 58 | + |
| 59 | + if( Event.current.type == EventType.Repaint ) |
| 60 | + MeshInstanceManager.UpdateHelperSurfaces(); |
| 61 | + |
| 62 | + if( Event.current.type == EventType.Repaint ) |
| 63 | + { |
| 64 | + SceneToolRenderer.OnPaint( sceneView ); |
| 65 | + } |
| 66 | + else |
| 67 | + //if (fallbackGUI) |
| 68 | + { |
| 69 | + SceneViewBottomBarGUI.ShowGUI( sceneView ); |
63 | 70 | SceneViewInfoGUI.DrawInfoGUI( sceneView ); |
64 | | - } |
65 | | - |
66 | | - EditModeManager.OnSceneGUI(sceneView); |
67 | | - |
68 | | - //if (fallbackGUI) |
69 | | - { |
70 | | - TooltipUtility.InitToolTip(sceneView); |
71 | | - if (Event.current.type == EventType.Repaint) |
72 | | - { |
73 | | - SceneViewBottomBarGUI.ShowGUI(sceneView); |
74 | | - SceneViewInfoGUI.DrawInfoGUI( sceneView ); |
75 | | - } |
76 | | - if (!mousePressed) |
77 | | - { |
78 | | - Handles.BeginGUI(); |
79 | | - TooltipUtility.DrawToolTip(getLastRect: false); |
80 | | - Handles.EndGUI(); |
81 | | - } |
82 | | - } |
83 | | - |
84 | | - if (Event.current.type == EventType.Layout) |
| 71 | + } |
| 72 | + |
| 73 | + EditModeManager.OnSceneGUI( sceneView ); |
| 74 | + |
| 75 | + //if (fallbackGUI) |
| 76 | + { |
| 77 | + TooltipUtility.InitToolTip( sceneView ); |
| 78 | + |
| 79 | + if( Event.current.type == EventType.Repaint ) |
| 80 | + { |
| 81 | + SceneViewBottomBarGUI.ShowGUI( sceneView, false ); |
| 82 | + SceneViewInfoGUI.DrawInfoGUI( sceneView ); |
| 83 | + } |
| 84 | + |
| 85 | + if( !mousePressed ) |
| 86 | + { |
| 87 | + Handles.BeginGUI(); |
| 88 | + TooltipUtility.DrawToolTip( getLastRect: false ); |
| 89 | + Handles.EndGUI(); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + if( Event.current.type == EventType.Layout ) |
85 | 94 | { |
86 | 95 | var currentFocusControl = CSGHandles.FocusControl; |
87 | | - if (prevFocusControl != currentFocusControl) |
| 96 | + |
| 97 | + if( prevFocusControl != currentFocusControl ) |
88 | 98 | { |
89 | 99 | prevFocusControl = currentFocusControl; |
90 | 100 | HandleUtility.Repaint(); |
91 | 101 | } |
92 | 102 | } |
93 | | - } |
94 | | - } |
| 103 | + } |
| 104 | + } |
95 | 105 | } |
0 commit comments