Guest User

Untitled

a guest
Jun 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Reflection;
  3. using UnityEditor;
  4.  
  5. [InitializeOnLoad]
  6. public static class GameViewScaleFixer
  7. {
  8. private static Assembly m_assembly = Assembly.Load( "UnityEditor.dll" );
  9. private static Type m_type = m_assembly.GetType( "UnityEditor.GameView" );
  10. private static BindingFlags m_bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static;
  11. private static MethodInfo m_snapZoomMethod = m_type.GetMethod( "SnapZoom", m_bindingAttr );
  12. private static object[] m_parameters = new object[] { 1f };
  13.  
  14. static GameViewScaleFixer()
  15. {
  16. EditorApplication.update += OnUpdate;
  17. }
  18.  
  19. private static void OnUpdate()
  20. {
  21. var gameView = EditorWindow.GetWindow( m_type );
  22. if ( gameView == null ) return;
  23. m_snapZoomMethod.Invoke( gameView, m_parameters );
  24. }
  25. }
Add Comment
Please, Sign In to add comment