コード例 #1
0
ファイル: GazeController.cs プロジェクト: rupertMme/Painter
        private Rect getOffsetFromGameView()
        {
            var unityEditorType       = Type.GetType("UnityEditor.GameView,UnityEditor");
            var getMainGameViewMethod = unityEditorType.GetMethod("GetMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);

            UnityEditor.EditorWindow result = getMainGameViewMethod.Invoke(null, null) as UnityEditor.EditorWindow;
            return(result.position);
        }
コード例 #2
0
 public static void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView)
 {
     UnityEditorInternal.RenderDoc.Load();
     System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
     Type type = assembly.GetType("UnityEditor.GameView");
     gameView = UnityEditor.EditorWindow.GetWindow(type);
     UnityEditorInternal.RenderDoc.BeginCaptureRenderDoc(gameView);
 }
コード例 #3
0
ファイル: ScreenHelpers.cs プロジェクト: johnmquick/exbeams
    private ScreenHelpers()
    {
        _hwnd = Win32Helpers.GetForegroundWindow();
        _windowId = _hwnd.ToString();

        #if UNITY_EDITOR
        _gameWindow = GetMainGameView();
        #endif
    }
コード例 #4
0
        protected override string GetFocusedEditorWindowTitle()
        {
#if UNITY_EDITOR
            UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow;
            return(window != null ? window.title : string.Empty);
#else
            return(string.Empty);
#endif
        }
コード例 #5
0
        public static Rect GetGameViewPosition()
        {
#if UNITY_EDITOR
            System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); //UnityEditor
            UnityEditor.EditorWindow gameview = UnityEditor.EditorWindow.GetWindow(T);
            return(gameview.position);                                               // gameview.position;
#else
            return(new Rect());
#endif
        }
コード例 #6
0
        private void FullScreen_OnValueChange(object sender, bool e)
        {
#if UNITY_EDITOR
            UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow;
            // Assume the game view is focused.
            window.maximized = e;
#else
            Screen.fullScreen = e;
#endif
        }
コード例 #7
0
ファイル: Ext.cs プロジェクト: Lucas1805/Teek_AR
        public static void CenterOnMainWin(this UnityEditor.EditorWindow aWin)
        {
            var   main = GetEditorMainWindowPos();
            var   pos  = aWin.position;
            float w    = (main.width - pos.width) * 0.5f;
            float h    = (main.height - pos.height) * 0.5f;

            pos.x         = main.x + w;
            pos.y         = main.y + h;
            aWin.position = pos;
        }
コード例 #8
0
 static public void CloseReadme(Component component)
 {
     System.Type t = GetWindowType();
     if (t != null)
     {
         UnityEditor.EditorWindow w = t.GetMethod("GetInstanceIfExists").Invoke(null, null) as UnityEditor.EditorWindow;
         if (w != null)
         {
             t.GetMethod("CloseIfOurs").Invoke(w, new object[] { component });
         }
     }
 }
コード例 #9
0
        static void EnsureGameViewReference()
        {
            if (gameViewType == null)
            {
                gameViewType = Type.GetType("UnityEditor.GameView,UnityEditor");
            }

            if (gameViewWindow == null)
            {
                gameViewWindow = UnityEditor.EditorWindow.GetWindowWithRect(gameViewType, new Rect(0, 0, 500, 500));
            }
        }
コード例 #10
0
        public string GetFocusedEditorWindowTitle()
        {
#if UNITY_EDITOR
            UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow;
#if UNITY_2017_PLUS
            return(window != null ? window.titleContent.text : string.Empty);
#else
            return(window != null ? window.title : string.Empty);
#endif
#else
            return(string.Empty);
#endif
        }
コード例 #11
0
        public static void CenterOnApplicationWindow(this UnityEditor.EditorWindow window, Vector2?size = null)
        {
            var main = GetApplicationScreenRect();
            var pos  = window.position;

            pos.size = size.GetValueOrDefault(pos.size);
            float w = (main.width - pos.width) * 0.5f;
            float h = (main.height - pos.height) * 0.5f;

            pos.x           = main.x + w;
            pos.y           = main.y + h;
            window.position = pos;
        }
コード例 #12
0
ファイル: Ext.cs プロジェクト: Lucas1805/Teek_AR
        public static void CenterOnMainWinAsPortrait(this UnityEditor.EditorWindow aWin)
        {
            var main = GetEditorMainWindowPos();
            var pos  = aWin.position;

            pos.height = main.height - (main.height / 10);
            pos.width  = (pos.height / 4) * 3;            //main.width / 2;
            float w = (main.width - pos.width) * 0.5f;
            float h = (main.height - pos.height) * 0.5f;

            pos.x         = main.x + w;
            pos.y         = main.y + h;
            aWin.position = pos;
        }
コード例 #13
0
    private void Update()
    {
        //Unity sometimes generates an error when the window is closed from the OnGUI function.
        //So We close it here
        if (m_close)
        {
            Close();

            if (LastFocusedWindow)
            {
                UnityEditor.EditorApplication.delayCall += LastFocusedWindow.Repaint;
                LastFocusedWindow = null;
            }
        }
    }
コード例 #14
0
 public void GUIUpdate(UnityEditor.EditorWindow window)
 {
     _zoom = Mathf.Lerp(previousZoom, targetZoom, (Time.realtimeSinceStartup - timeZoomRequested) / zoomEffectDuration);
     if (Event.current.type == EventType.Repaint)
     {
         if (_zoom == targetZoom)
         {
             IsZooming = false;
         }
         else
         {
             window.Repaint();
         }
     }
 }
コード例 #15
0
        private void repaintGameView()
        {
                        #if UNITY_EDITOR
            if (getMainGameViewMethod == null)
            {
                initGameViewMethod();
            }

            UnityEditor.EditorWindow gameviewWindow = (UnityEditor.EditorWindow)getMainGameViewMethod.Invoke(null, null);
            if (gameviewWindow != null)
            {
                gameviewWindow.Repaint();
            }
                        #endif
        }
コード例 #16
0
        private static bool IsGameViewVSyncEnabled()
        {
            bool result = true;

#if UNITY_EDITOR && UNITY_2019_1_OR_NEWER
            System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
            System.Type type = assembly.GetType("UnityEditor.GameView");
            UnityEditor.EditorWindow       window = UnityEditor.EditorWindow.GetWindow(type);
            System.Reflection.PropertyInfo prop   = type.GetProperty("vSyncEnabled");
            if (prop != null)
            {
                result = (bool)prop.GetValue(window);
            }
#endif
            return(result);
        }
コード例 #17
0
        static public void ShowReadme(string name, string text, bool richText, bool markdownish, Component component, bool force)
        {
            if (!ShouldShowReadme(force))
            {
                return;
            }

            System.Type t = GetWindowType();
            if (t != null)
            {
                UnityEditor.EditorWindow w = t.GetMethod("GetInstance").Invoke(null, null) as UnityEditor.EditorWindow;
                if (w != null)
                {
                    t.GetMethod("SetContent").Invoke(w, new object[] { name, text, richText, markdownish, component });
                    w.ShowUtility();
                }
            }
        }
コード例 #18
0
 public static void CenterOnMainWin(this UnityEditor.EditorWindow aWin)
 {
     try
     {
         var   main = GetEditorMainWindowPos();
         var   pos  = aWin.position;
         float w    = (main.width - pos.width) * 0.5f;
         float h    = (main.height - pos.height) * 0.5f;
         pos.x         = main.x + w;
         pos.y         = main.y + h;
         aWin.position = pos;
     }
     catch (NotSupportedException e)
     {
         Debug.LogWarning(
             "The editor window wasn't centered: " + e
             );
     }
 }
コード例 #19
0
            private static string GetSelectedStackTrace()
            {
                Assembly editorWindowAssembly = typeof(UnityEditor.EditorWindow).Assembly;

                if (editorWindowAssembly == null)
                {
                    return(null);
                }

                System.Type consoleWindowType = editorWindowAssembly.GetType("UnityEditor.ConsoleWindow");
                if (consoleWindowType == null)
                {
                    return(null);
                }

                FieldInfo consoleWindowFieldInfo = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic);

                if (consoleWindowFieldInfo == null)
                {
                    return(null);
                }

                UnityEditor.EditorWindow consoleWindow = consoleWindowFieldInfo.GetValue(null) as UnityEditor.EditorWindow;
                if (consoleWindow == null)
                {
                    return(null);
                }

                if (consoleWindow != UnityEditor.EditorWindow.focusedWindow)
                {
                    return(null);
                }

                FieldInfo activeTextFieldInfo = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic);

                if (activeTextFieldInfo == null)
                {
                    return(null);
                }

                return((string)activeTextFieldInfo.GetValue(consoleWindow));
            }
コード例 #20
0
        public void OnEnable()
        {
            //Debug.Log("Spout.OnEnable");
            if (_instance != null && _instance != this)
            {
                //Debug.Log("Spout.OnEnable.Destroy");
                                #if UNITY_EDITOR
                DestroyImmediate(this.gameObject);
                                #else
                Destroy(this.gameObject);
                                #endif
                return;
            }

            newSenders         = new List <TextureInfo>();
            stoppedSenders     = new List <TextureInfo>();
            activeSenders      = new List <TextureInfo>();
            activeLocalSenders = new List <TextureInfo>();
            localSenderNames   = new HashSet <string>();

                        #if UNITY_EDITOR
            assembly     = typeof(UnityEditor.EditorWindow).Assembly;
            gameviewType = assembly.GetType("UnityEditor.GameView");
            gameview     = UnityEditor.EditorWindow.GetWindow(gameviewType);
                        #endif


#if UNITY_EDITOR
            if (_isEnabledInEditor || Application.isPlaying)
            {
                _Enable();
            }
#else
            _Enable();
#endif
        }
コード例 #21
0
 public zFullWindow(UnityEditor.EditorWindow window)
 {
     win = window;
 }
コード例 #22
0
 private void Initialize()
 {
     _gameWindow = GetMainGameView();
     _windowParentBoundsAccessor = GetWindowParentBoundsAccessor(_gameWindow);
     _toolbarHeight = GetToolbarHeight();        
     _initialized = true;
 }
コード例 #23
0
 private void Initialize()
 {
     _gameWindow = GetMainGameView();
     _initialized = true;
 }
コード例 #24
0
ファイル: MiscExtensions.cs プロジェクト: vfqd/piranesi
        public static void CenterInScreen(this UnityEditor.EditorWindow window, float width, float height)
        {
            Vector2Int resolution = ResolutionOption.GetLargestSupportedResolution().Dimensions;

            window.position = new Rect((resolution.x - width) * 0.5f, (resolution.y - height) * 0.5f, width, height);
        }
コード例 #25
0
 public static void EndCaptureRenderDoc(UnityEditor.EditorWindow window)
 => window.m_Parent.EndCaptureRenderDoc();
コード例 #26
0
 private void Initialize()
 {
     _gameWindow  = GetMainGameView();
     _initialized = true;
 }
コード例 #27
0
ファイル: Spout.cs プロジェクト: polygon-studios/house
		public void OnEnable(){
			//Debug.Log("Spout.OnEnable");
			if(_instance != null && _instance != this )
			{
				//Debug.Log("Spout.OnEnable.Destroy");
				#if UNITY_EDITOR
				DestroyImmediate(this.gameObject);
				#else
				Destroy(this.gameObject);
				#endif
				return;
			}

			newSenders = new List<TextureInfo>();
			stoppedSenders = new List<TextureInfo>();
			activeSenders = new List<TextureInfo>();
			activeLocalSenders = new List<TextureInfo>();
			localSenderNames = new HashSet<string>();
			
			#if UNITY_EDITOR
			assembly = typeof(UnityEditor.EditorWindow).Assembly;
			gameviewType = assembly.GetType( "UnityEditor.GameView" );
			gameview = UnityEditor.EditorWindow.GetWindow(gameviewType);
			#endif


#if UNITY_EDITOR
			if(_isEnabledInEditor || Application.isPlaying){
				_Enable();
			}
#else
			_Enable();
#endif
			

		}
コード例 #28
0
 /// <summary>
 /// 显示一个Tip信息
 /// </summary>
 /// <param name="thisRef"></param>
 /// <param name="content"></param>
 public static void ShowTip(this UnityEditor.EditorWindow thisRef, string content)
 {
     thisRef.ShowNotification(new UnityEngine.GUIContent(content));
 }
コード例 #29
0
 public static bool IsWindowOpened(UnityEditor.EditorWindow win) => _allOpenedWindows.Values.Where(s => s == win).Count() > 0;
コード例 #30
0
 public UnityEditorIMGUIControlsTreeViewController(UnityEditor.EditorWindow editorWindow, UnityEditor.IMGUI.Controls.TreeViewState treeViewState)
 {
     m_instance = Activator.CreateInstance(UnityTypes.UnityEditor_IMGUI_Controls_TreeViewController, new object[] { editorWindow, treeViewState });
 }