- Home /
Deactivate display (multi-display)
Says it in the title but to clarify... When using multiple monitors you can call the Display.displays.Activate() to activate the application on more than one screen. But how do you deactivate a secondary screen without having to restart. Else is it advisable not to use multi-displays, because I haven't seen much support for it?
Have you found a workaround? Been trying to get around this issue.
I've created a post on Feedback for this request https://feedback.unity3d.com/suggestions/multi-display-display-dot-deactivate-function
Answer by DizzyWascal · Jun 18, 2018 at 10:25 AM
I finally got a workaround but only for Windows.
Since the name of the Secondary Display is always "Unity Secondary Display" I just created a .exe using .Net Framework to find and hide it fully.
The script and the exe can be downloaded here.
Will need to figure out code for linux and mac however.
To apply in runtime just have that .exe file somewhere and use the code:
Process process = new Process();
// Stop the process from opening a new window
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
// Setup executable and parameters
process.StartInfo.FileName = @Application.streamingAssetsPath + "/" + "Third Party Functions/Minimise Secondary Display/Windows/Windows-Minimise-Secondary.exe";
//process.StartInfo.Arguments = "--test";
// Go
process.Start();
In my case I put it into my Streaming Asset Path.
Also forgot to mention for the code it will require
using System.Diagnostics;
Thanks for the answer! This is quite a hacky solution but looks like it works on windows. Personally I no longer need this capability but I hope this helps others.
A year's necromancy on this thread, but can this work with three screens (i.e. a main display and two displays on either side)? They're both called "Unity Secondary Display" but the .exe only disables one, even if it is run twice it'll never disable the third screen.
Thanks if you reply!
Answer by mikelortega · May 04, 2018 at 01:08 PM
Once activated, you cannot deactivate a display. It's explained in the documentation.
About if it's advisable using multi-display... well, sometimes you don't have another option and it works, but the functions are limited and I think that not everything works as expected. I hope they improve it in the future.
That is true. I removed the unnecessary folders and files (e.g. Project Settings, Temp , .csproj, .sln). Opened the project, did a new build and the second screen was gone.
Your answer

Follow this Question
Related Questions
Display.displays length not updating 2 Answers
How to get Display.display[] to recognize a display other than Display.main? 0 Answers
I want one Canvas to show the same thing on two multi-displays. 0 Answers
Display.displays.length always returns 1 2 Answers
MultiDisplay - main display resolution changes itself to native 0 Answers