Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [InitializeOnLoad]
- public class KeepInactiveSceneViewsStill : MonoBehaviour
- {
- static Dictionary<SceneView, Vector3> sceneview2pivot = new Dictionary<SceneView, Vector3>();
- static KeepInactiveSceneViewsStill()
- {
- SceneView.onSceneGUIDelegate += OnSceneGUI;
- }
- static void OnSceneGUI(SceneView sceneView)
- {
- // prevent all views from moving except the active one
- foreach( SceneView sv in SceneView.sceneViews )
- {
- if( !sceneview2pivot.ContainsKey(sv) )
- sceneview2pivot[sv] = sv.pivot;
- // reset pivot if not active
- if( SceneView.lastActiveSceneView != sv )
- sv.pivot = sceneview2pivot[sv];
- else
- {
- // it's active, update its position
- sceneview2pivot[sv] = sv.pivot;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment