Search Issue Tracker
Fixed in 2021.2.X
Votes
2
Found in
2019.4
2019.4.13f1
2020.2
2021.1
2021.2
Issue ID
1308923
Regression
No
System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle always returns 0 on builds
Reproduction steps:
1. Open attached project "WindowHandle.zip" and scene "SampleScene"
2. Build and Run
3. Open an additional instance of the built Application
3. In both builds, observe text field
Expected result: "Window Handle: " and at least one non-zero handle
Actual result: "Window Handle: 0" on both applications
Reproducible with: 2019.4.21f1, 2020.2.6f1, 2021.1.0b8, 2021.2.0a6
Could not test with: 2018.4.32f1 (multiple precompiled assemblies errors on build)
Comments (1)
-
JaredThomson
Feb 22, 2021 17:12
There are a lot of related issues with how little Unity and it's version of mono provides regarding the process and native window.
This particular bug could be changed to a feature request, but please don't just close it as being by design.
There are some legitimate use cases for knowing your process id and hwnd. My use case is debugging multiplayer by launching multiple instances of the standalone game and changing the window title and positions to differentiate the instances. This is made much more difficult with no process id or native handle. The common fragile work around of getting the handle by window title obviously doesn't work here either.
Thanks for any advancements that can be made here. Any step forward would be a big improvement.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "NullReferenceException" is thrown when setting a long string in TMP with "Atlas Population Mode" set to "Dynamic" and "Multi Atlas Textures" enabled
- TextMeshPro text is misaligned when alignment is set via script
- A DX11 shader error is thrown when compiling shaders for platforms without DX11 support
- Rigidbody2D.Slide correctly ignores colliders specified with "Physics2D.IgnoreCollision" however encountering them can still modify movement behaviour in subtle ways.
- [Quality Hackweek] A black separator appears when the left panel in the UI Builder tab is resized, and the tab is narrow
Resolution Note (fix version 2021.2):
Fixed in 2021.2.0a18