Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheBITLINK · Sep 28, 2015 at 06:43 AM · windowswindowshell

Is there any way to show/hide the game window on demand?

Short story:

I'm making a game with a level editor, the game itself is made in Unity, the Editor is made in WPF.

When the Editor is opened, the game establishes a TCP connection with the editor, and displays a blank scene with some GUIText with information about the connection.

I would like to hide the game window entirely, when the editor is in use, but i need to keep the game running in background so when people click "Test Level" in the editor, the level is started inmediatly, without having to wait the game to initialize and stuff.

Is there any way to hide and show the Game Window on demand?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image getyour411 · Sep 28, 2015 at 10:27 PM 0
Share

Could you have two cameras - one displaying Game Window and one displaying the other thing, both with full viewport rects, and enable/disable pause/unpause as needed?

avatar image TheBITLINK · Sep 30, 2015 at 08:38 PM 0
Share

The thing is... the editor has nothing to do with Unity, is a Standalone app...

avatar image getyour411 · Oct 01, 2015 at 05:36 AM 0
Share

You can probably force a $$anonymous$$imize of the Game Window via script but it sounds like you need to know how to do that from WPF code, not Unity. See this thread for some info on Unity code

http://answers.unity3d.com/questions/27490/$$anonymous$$imizing-and-maximizing-by-script.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OliverJackman · Sep 26, 2019 at 11:53 PM

Sure !

 using System;
  using UnityEngine;
  using System.Runtime.InteropServices;
  
  public class HideUnityWindow : MonoBehaviour
  {
      [DllImport("user32.dll")]
      private static extern IntPtr GetActiveWindow();
  
      [DllImport("user32.dll")]
      static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  
      const int SW_HIDE = 0;
  
      void Start()
      {
          var hwnd = GetActiveWindow();
          ShowWindow(hwnd, SW_HIDE);
  
      }
   
  }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity_6_EX02It3-nWnw · May 11, 2020 at 03:17 AM 0
Share

Would you be willing to explain the code a little bit? Or change the variable names to be a little more informative? I don't quite understand what I am seeing here.

Thank you

avatar image ProKillerMT · Dec 28, 2021 at 03:25 PM 0
Share

Is there a way to show the window after u hide it? @OliverJackman I tried the SW_RESTORE and the other SW Stuff, nothing worked D:

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to use "Microsoft-WindowsAPICodePack-Shell" in Unity? 0 Answers

Force aspect ratio of window (standalone Windows) 1 Answer

Why Unity correctly builds a project but the editor freezes on the Build Progress window? 2 Answers

How to fix small viewPort in GameRoom? 0 Answers

Absolute Window Position of Unity Application 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges