Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Unity always renders on top on win32. (HWND)

Discussion in 'Windows' started by Noah-01, Aug 16, 2021.

  1. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    use unity : 2020.3.15f2 (window 10)
    I am exporting the project to Visual Studio and working in Main.cpp .


    a childWindow was created in the win32 environment and rendered as a window window through the -parentHWND option.


    in windows order, unity should be at the back.


    but there is a problem that when I activate the Unity window, it renders to the front.


    Create one Root CreateWindow in win32 environment,

    I created two WS_CHILD boxes, Unity Window and Gray Window.

    And the order is arranged so that the Gray Window is at the top.

    When Unity is rendered, the Unity screen is always newer than the Gray Window.

    I tried minimizing the Unity window to check. If it is minimized, the order is obviously correct, but

    When re-enabled, the Unity window will rise to the top.

    I want to put the component window on top of the unity window.

    Ask for help.

    how can I adjust d window order in win32 environment?

    01.png 02.png
     
  2. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Looks like we do "SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);" when we receive WM_ACTIVATE window message, which would bring the window to the front. You could probably work around it by overwriting the WM_ACTIVATE message to change the window order in the way you expect it to be after Unity handles the message.
     
  4. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    제목 없음.png

    Code (CSharp):
    1. #include "PrecompiledHeader.h"
    2. #include "..\UnityPlayerStub\Exports.h"
    3. #include <stdio.h>
    4. #include <Processthreadsapi.h>
    5. #include <future>
    6. #include <iostream>
    7. #include <string>
    8. #include <Windows.h>
    9. #include <Windowsx.h>
    10.  
    11.  
    12. using namespace std;
    13.  
    14. #include <gl/GL.h>
    15. #include <gl/GLU.h>
    16.  
    17. // Hint that the discrete gpu should be enabled on optimus/enduro systems
    18. // NVIDIA docs: http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
    19. // AMD forum post: http://devgurus.amd.com/thread/169965
    20. extern "C"
    21. {
    22.     __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
    23.     __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
    24. }
    25.  
    26.  
    27. HWND rootHandle;
    28. HWND parentHandle;
    29. HWND grayHandle;
    30. HWND unityParentHandle;
    31. HWND unityHandle;
    32.  
    33.  
    34. LRESULT CALLBACK WndProc(HWND    hWnd,            // Handle For This Window
    35.     UINT    uMsg,            // Message For This Window
    36.     WPARAM    wParam,            // Additional Message Information
    37.     LPARAM    lParam)            // Additional Message Information
    38. {
    39.     return DefWindowProc(hWnd, uMsg, wParam, lParam);
    40. }
    41.  
    42.  
    43. typedef int (*unityFN)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd);
    44.  
    45.  
    46. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    47.  
    48. HINSTANCE g_hInst;
    49.  
    50. LPCTSTR lpszClass = TEXT("First");
    51.  
    52. constexpr const wchar_t kUnityWindowClassName[] = L"RUNNER_WIN32_WINDOW_UNITY";
    53. constexpr const wchar_t kWindowClassName[] = L"RUNNER_WIN32_WINDOW_UNITY1";
    54.  
    55. // scale factor
    56. int Scale(int source, double scale_factor) {
    57.     return static_cast<int>(source * scale_factor);
    58. }
    59.  
    60. LRESULT CALLBACK UnityWndProc(HWND const window,
    61.     UINT const message,
    62.     WPARAM const wparam,
    63.     LPARAM const lparam) noexcept {
    64.  
    65.     LRESULT result = DefWindowProc(window, message, wparam, lparam);
    66.  
    67.     if (message == WM_ACTIVATE) {
    68.         printf("WM_ACTIVATE");
    69.  
    70.         if (wparam == WA_ACTIVE) {
    71.             return 0;
    72.         }
    73.  
    74.     }
    75.     else if (message == WM_ACTIVATEAPP) {
    76.         printf("WM_ACTIVATEAPP");
    77.     }
    78.  
    79.     SetWindowPos(unityHandle, HWND_BOTTOM, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    80.     //SetWindowPos(unityParentHandle, grayHandle, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    81.     SetWindowPos(grayHandle, HWND_NOTOPMOST, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    82.  
    83.    
    84.    
    85.     return result;
    86. }
    87.  
    88.  
    89.  
    90. void FindUnityWindow(HWND hWnd, LPARAM lParam) {
    91.  
    92.     unityHandle = hWnd;
    93.  
    94.     auto mainThread = GetWindowThreadProcessId(reinterpret_cast<HWND>(rootHandle), nullptr);
    95.     auto unityMainThread = GetWindowThreadProcessId(unityHandle, nullptr);
    96.     AttachThreadInput(mainThread, unityMainThread, FALSE);
    97.     AttachThreadInput(unityMainThread, mainThread, FALSE);
    98.  
    99.     SendMessageA(hWnd, WM_ACTIVATE, WA_ACTIVE, 0);
    100.     MoveWindow(unityHandle, 0, 0, 150, 150, true);
    101. }
    102.  
    103. BOOL CALLBACK FindProcessesWindowEnum(HWND hWnd, LPARAM lParam)
    104. {
    105.     TCHAR className[256] = { 0 };
    106.     GetClassName(hWnd, className, 256);
    107.  
    108.     if (className != NULL && wcscmp(className, L"UnityWndClass") == 0) {
    109.         FindUnityWindow(hWnd, lParam);
    110.         return true;
    111.     }
    112.  
    113.     return false;
    114. }
    115.  
    116. void thread_function(HWND child, HWND parent, HWND gray)
    117. {
    118.  
    119.     unityParentHandle = child;
    120.     parentHandle = parent;
    121.     grayHandle = gray;
    122.  
    123.     //ShowWindow(child, SW_SHOWMINNOACTIVE);
    124.  
    125.     //SetWindowPos(parent, HWND_TOPMOST, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    126.  
    127.  
    128.     while (unityHandle == nullptr)
    129.         EnumChildWindows(child, FindProcessesWindowEnum, NULL);
    130.  
    131.  
    132.     //SetParent(child, parent);
    133.     //SetWindowPos(child, HWND_BOTTOM, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    134.  
    135.  
    136. }
    137.  
    138.  
    139.  
    140.  
    141. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
    142. {
    143.  
    144.     HWND hWnd;
    145.     MSG Message;
    146.     WNDCLASS WndClass;
    147.     g_hInst = hInstance;
    148.  
    149.     WndClass.cbClsExtra = 0;
    150.     WndClass.cbWndExtra = 0;
    151.     WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    152.     WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    153.     WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    154.     WndClass.hInstance = hInstance;
    155.     WndClass.lpfnWndProc = WndProc;
    156.     WndClass.lpszClassName = lpszClass;
    157.     WndClass.lpszMenuName = NULL;
    158.     WndClass.style = CS_HREDRAW | CS_VREDRAW;
    159.     RegisterClass(&WndClass);
    160.  
    161.     hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    162.         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
    163.         NULL, (HMENU)NULL, hInstance, NULL);
    164.  
    165.     ShowWindow(hWnd, nShowCmd);
    166.  
    167.     WNDCLASS unity_window_class{};
    168.     unity_window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
    169.     unity_window_class.lpszClassName = kUnityWindowClassName;
    170.     unity_window_class.style = CS_HREDRAW | CS_VREDRAW;
    171.     unity_window_class.cbClsExtra = 0;
    172.     unity_window_class.cbWndExtra = 0;
    173.     unity_window_class.hInstance = GetModuleHandle(nullptr);
    174.  
    175.     //window_class.hbrBackground = 0;
    176.     unity_window_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    177.     unity_window_class.lpszMenuName = nullptr;
    178.     unity_window_class.lpfnWndProc = UnityWndProc;
    179.     RegisterClass(&unity_window_class);
    180.  
    181.  
    182.     HWND window = CreateWindow(kUnityWindowClassName, L"aa", WS_VISIBLE | WS_CHILD, 0, 0, 200, 200, hWnd, nullptr, (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), NULL);
    183.  
    184.  
    185.     WNDCLASS window_class{};
    186.     window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
    187.     window_class.lpszClassName = kWindowClassName;
    188.     window_class.style = CS_HREDRAW | CS_VREDRAW;
    189.     window_class.cbClsExtra = 0;
    190.     window_class.cbWndExtra = 0;
    191.     window_class.hInstance = GetModuleHandle(nullptr);
    192.  
    193.     //window_class.hbrBackground = 0;
    194.     window_class.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
    195.     window_class.lpszMenuName = nullptr;
    196.     window_class.lpfnWndProc = WndProc;
    197.     RegisterClass(&window_class);
    198.  
    199.  
    200.     HWND window2 = CreateWindow(kWindowClassName, L"aaaa", WS_VISIBLE | WS_CHILD, 50, 50, 200, 200, hWnd, nullptr, (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), NULL);
    201.  
    202.     //SetParent(window, window2);
    203.  
    204.     /*
    205.     Win32Window window;
    206.     Win32Window::Point origin(10, 10);
    207.     Win32Window::Size size(1280, 720);
    208.     window.CreateAndShow(L"flutter_acrylic_example", origin, size);
    209.  
    210.     const int hwndParamsSize = 10;
    211.     const int showCmd = 10;
    212.     auto dllHandle = LoadLibrary(L"UnityPlayer.dll");
    213.     auto funcHandle = GetProcAddress(dllHandle, "UnityMain");
    214.     unityFN unityFunc = (unityFN)funcHandle;
    215.  
    216.     auto cmd = GetCommandLine();
    217.     auto hwndStr = std::to_wstring((int)hWnd);
    218.     auto cmdStr = std::wstring(cmd);
    219.     int i = cmdStr.size() - hwndParamsSize;
    220.     for (int j = 0; i < cmdStr.size() - hwndParamsSize + hwndStr.size(); i++, j++)
    221.     {
    222.         cmd[i] = hwndStr[j];
    223.     }
    224.     cmd[i] = 0;
    225.  
    226.     unityFunc(0, 0, L"", showCmd);
    227.     */
    228.     std::string scmdLine = std::string("-parentHWND ") + std::to_string((uint64_t)window).c_str();
    229.  
    230.     //std::string scmdLine = std::string("-parentHWND '") + std::to_string((uint64_t)window).c_str() + std::string("' delayed");
    231.  
    232.     LPWSTR output = NULL;
    233.     int lenA = lstrlenA(scmdLine.c_str());
    234.     int lenW = ::MultiByteToWideChar(CP_ACP, 0, scmdLine.c_str(), lenA, NULL, 0);
    235.     if (lenW > 0)
    236.     {
    237.         output = new wchar_t[lenW];
    238.         ::MultiByteToWideChar(CP_ACP, 0, scmdLine.c_str(), lenA, output, lenW);
    239.     }
    240.  
    241.     rootHandle = hWnd;
    242.  
    243.     thread _t1(thread_function, window, hWnd, window2);
    244.  
    245.     UnityMain(hInstance, hPrevInstance, output, nShowCmd);
    246.  
    247.     while (GetMessage(&Message, NULL, 0, 0))
    248.     {
    249.  
    250.         TranslateMessage(&Message);
    251.         DispatchMessage(&Message);
    252.  
    253.     }
    254.  
    255.     return (int)Message.wParam;
    256. }
    257.  
     
  5. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    As you can see, no matter what you do, the Unity render window is always on top.
    Can you tell me what I'm doing wrong in the code?
    The white window is the parent window of Unity passed as args.
    I want to feed the
    z-order in the same way as the parent window.
     
  6. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    Please check the comments above, I have been having a difficult issue for a few weeks.
    thank you.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    When you enumerate the child windows to find the Unity window, you can call "SetWindowLongPtr" with "GWL_WNDPROC" to replace our WndProc with your own (the return value is the old WndProc value). In there, you should call the original WndProc, but after it returns, check if the message was "WM_ACTIVATE" and if it was, you can change the window order right there.
     
  8. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    I changed it through SetWindowLongPtr ,

    WM_ACTIVATE was received.

    But no change...

    What am I doing wrong here?

    Code (CSharp):
    1.  
    2. WNDPROC prevWndProc;
    3. LRESULT __stdcall UnityWndProc(HWND const window,
    4.     UINT const message,
    5.     WPARAM const wparam,
    6.     LPARAM const lparam) noexcept {
    7.  
    8.     if (message == WM_ACTIVATE) {
    9.  
    10.         if (wparam == WA_ACTIVE) {
    11.             LRESULT result = CallWindowProc(prevWndProc, window, message, wparam, lparam);
    12.  
    13.             SetWindowPos(window, HWND_BOTTOM, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    14.             SetWindowPos(grayHandle, HWND_TOPMOST, 80, 80, 200, 200, SWP_NOMOVE | SWP_NOSIZE);
    15.  
    16.             return result;          
    17.         }
    18.  
    19.  
    20.     }
    21.    
    22.     return DefWindowProc(window, message, wparam, lparam);
    23. }
    24.  
    25. void FindUnityWindow(HWND hWnd, LPARAM lParam) {
    26.  
    27.     unityHandle = hWnd;
    28.  
    29.     prevWndProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(UnityWndProc)));
    30.  
    31.     auto mainThread = GetWindowThreadProcessId(reinterpret_cast<HWND>(rootHandle), nullptr);
    32.     auto unityMainThread = GetWindowThreadProcessId(unityHandle, nullptr);
    33.     AttachThreadInput(mainThread, unityMainThread, FALSE);
    34.     AttachThreadInput(unityMainThread, mainThread, FALSE);
    35.  
    36.     SendMessage(hWnd, WM_ACTIVATE, WA_ACTIVE, 0);
    37.     MoveWindow(unityHandle, 0, 0, 150, 150, true);
    38. }
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    You probably always want to call prevWndProc, and then if message is WM_ACTIVATE with WA_ACTIVE, call SetWindowPos. If that doesn't work, perhaps try using a tool like Spy++ to see how that window gets set to render on top?
     
  10. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    If you check with spy++ through the above source code, you have the lower layer.

    upload_2021-8-17_23-23-36.png

    upload_2021-8-18_3-46-24.png
     
    Last edited: Aug 17, 2021
  11. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    I tried adjusting the Windows HWND in real time.

    It is confirmed that Unity's render area is still eating TOP.
    (Look at the order of overlapping window bars on the screen)

    ChildWindow is placed on top, but Unity's OpenGL View area is the problem.


    upload_2021-8-18_3-53-52.png
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Are you using OpenGL in your player settings? Does this reproduce on DirectX? It looks like the child window is actually on top, but for some reason the swapchain gets rendered on top of that.
     
  13. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    I'm using OpenGL with the standard build.

    This is to use Windows Unity as a framework, and it is necessary to mix Unity and UI frameworks.
     
    Last edited: Aug 18, 2021
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Can you show me your player log? We don't really have samples for something like this.
     
  15. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    I was running with the OpenGL Core graphics engine.


    PlayerConnection initialized from C:/Users/Noah/Documents/EmbeddedWindow-1/build/bin/EmbeddedWindow_Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55340
    Multi-casting "[IP] 118.220.130.140 [Port] 55340 [Flags] 2 [Guid] 3725785989 [EditorId] 1648985591 [Version] 1048832 [Id] WindowsPlayer(NOAH-IMAC-5K) [Debug] 0 [PackageName] WindowsPlayer [ProjectName] EmbeddedWindow" to [225.0.0.222:54997]...
    Started listening to [0.0.0.0:55340]
    PlayerConnection already initialized - listening to [0.0.0.0:55340]
    Initialize engine version: 2020.3.15f2 (6cf78cb77498)
    [Subsystems] Discovering subsystems at path C:/Users/Noah/Documents/EmbeddedWindow-1/build/bin/EmbeddedWindow_Data/UnitySubsystems
    GfxDevice: creating device client; threaded=1
    Renderer: AMD Radeon Pro 5700 XT
    Vendor: ATI Technologies Inc.
    Version: 4.5.13587 Core Profile Forward-Compatible/Debug Context FireGL 19.50.32.03 26.20.15032.3004
    GLES: 0
    GL_AMDX_debug_output GL_AMD_blend_minmax_factor GL_AMD_conservative_depth GL_AMD_debug_output GL_AMD_depth_clamp_separate GL_AMD_draw_buffers_blend GL_AMD_framebuffer_sample_positions GL_AMD_gcn_shader GL_AMD_gpu_shader_half_float GL_AMD_gpu_shader_half_float_fetch GL_AMD_gpu_shader_int16 GL_AMD_gpu_shader_int64 GL_AMD_interleaved_elements GL_AMD_multi_draw_indirect GL_AMD_name_gen_delete GL_AMD_occlusion_query_event GL_AMD_performance_monitor GL_AMD_pinned_memory GL_AMD_query_buffer_object GL_AMD_sample_positions GL_AMD_seamless_cubemap_per_texture GL_AMD_shader_atomic_counter_ops GL_AMD_shader_stencil_export GL_AMD_shader_stencil_value_export GL_AMD_shader_trace GL_AMD_shader_trinary_minmax GL_AMD_sparse_texture GL_AMD_sparse_texture_pool GL_AMD_stencil_operation_extended GL_AMD_texture_cube_map_array GL_AMD_texture_texture4 GL_AMD_transform_feedback3_lines_triangles GL_AMD_transform_feedback4 GL_AMD_vertex_shader_layer GL_AMD_vertex_shader_viewport_index GL_ARB_ES2_compatibility GL_ARB_ES3_1_compatibilit
    y GL_ARB_ES3_compatibility GL_ARB_arrays_of_arrays GL_ARB_base_instance GL_ARB_bindless_texture GL_ARB_blend_func_extended GL_ARB_buffer_storage GL_ARB_clear_buffer_object GL_ARB_clear_texture GL_ARB_clip_control GL_ARB_color_buffer_float GL_ARB_compressed_texture_pixel_storage GL_ARB_compute_shader GL_ARB_conditional_render_inverted GL_ARB_conservative_depth GL_ARB_copy_buffer GL_ARB_copy_image GL_ARB_cull_distance GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_derivative_control GL_ARB_direct_state_access GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_elements_base_vertex GL_ARB_draw_indirect GL_ARB_draw_instanced GL_ARB_enhanced_layouts GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_layer_viewport GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_no_attachments GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_geometry_shader4 GL
    _ARB_get_program_binary GL_ARB_get_texture_sub_image GL_ARB_gl_spirv GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_indirect_parameters GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multi_bind GL_ARB_multi_draw_indirect GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_parallel_shader_compile GL_ARB_pipeline_statistics_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_polygon_offset_clamp GL_ARB_program_interface_query GL_ARB_provoking_vertex GL_ARB_query_buffer_object GL_ARB_robust_buffer_access_behavior GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_separate_shader_objects GL_ARB_shader_atomic_counters GL_ARB_shader_ballot GL_ARB_shader_bit_encoding GL_ARB_shader_draw_parameters GL_A
    RB_shader_group_vote GL_ARB_shader_image_load_store GL_ARB_shader_image_size GL_ARB_shader_objects GL_ARB_shader_precision GL_ARB_shader_stencil_export GL_ARB_shader_storage_buffer_object GL_ARB_shader_subroutine GL_ARB_shader_texture_image_samples GL_ARB_shader_texture_lod GL_ARB_shader_viewport_layer_array GL_ARB_shading_language_100 GL_ARB_shading_language_420pack GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_shadow_ambient GL_ARB_sparse_buffer GL_ARB_sparse_texture GL_ARB_spirv_extensions GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_tessellation_shader GL_ARB_texture_barrier GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_buffer_range GL_ARB_texture_compression GL_ARB_texture_compression_bptc GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirror
    _clamp_to_edge GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_query_lod GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a2ui GL_ARB_texture_snorm GL_ARB_texture_stencil8 GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_swizzle GL_ARB_texture_view GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_transform_feedback_instanced GL_ARB_transform_feedback_overflow_query GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_64bit GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_envmap_bumpmap GL_ATI_fragment_shader GL_ATI_meminfo GL_ATI_separate_stencil GL_ATI_texture_compression_3dc GL_ATI_texture_env_combi
    ne3 GL_ATI_texture_float GL_ATI_texture_mirror_once GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_copy_buffer GL_EXT_copy_texture GL_EXT_depth_bounds_test GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_histogram GL_EXT_memory_object GL_EXT_memory_object_win32 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_polygon_offset_clamp GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_semaphore GL_EXT_semaphore_win32 GL_EXT_separate_specular_color GL_EXT_shader_image_load_store GL_EXT_sha
    der_integer_mix GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_EXT_subtexture GL_EXT_texgen_reflection GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_bptc GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_EXT_texture_sRGB_decode GL_EXT_texture_shared_exponent GL_EXT_texture_snorm GL_EXT_texture_storage GL_EXT_texture_swizzle GL_EXT_timer_query GL_EXT_transform_feedback GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_EXT_vertex_attrib_64bit GL_IBM_texture_mirrored_repeat GL_INTEL_fragment_shader_ordering GL_KHR_context_flush_control GL_KHR_debug GL_KHR_no_erro
    r GL_KHR_parallel_shader_compile GL_KHR_robust_buffer_access_behavior GL_KHR_robustness GL_KTX_buffer_region GL_NV_alpha_to_coverage_dither_control GL_NV_blend_square GL_NV_conditional_render GL_NV_copy_depth_to_color GL_NV_copy_image GL_NV_depth_buffer_float GL_NV_explicit_multisample GL_NV_float_buffer GL_NV_half_float GL_NV_primitive_restart GL_NV_shader_atomic_int64 GL_NV_texgen_reflection GL_NV_texture_barrier GL_OES_EGL_image GL_SGIS_generate_mipmap GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays GL_WIN_swap_hint WGL_EXT_swap_control
    OPENGL LOG: Creating OpenGL 4.5 graphics device ; Context level <OpenGL 4.5> ; Context handle 65537
    Microsoft Media Foundation video decoding to texture disabled: graphics device is OpenGL Core, only Direct3D 11 and Direct3D 12 (only on desktop) are supported.
    <RI> Initializing input.
    <RI> Input initialized.
    <RI> Initialized touch support.
    UnloadTime: 7.148900 ms

     
  16. Noah-01

    Noah-01

    Joined:
    Aug 11, 2021
    Posts:
    12
    Direct also has the same problem.
    I must use OpenGL.
    you can reproduce it by creating a Unity empty project and pasting the corresponding CPP file.
    I need a solution to put another UI component on top of the Unity Window. Ask for help.

    upload_2021-8-18_23-1-26.png
     

    Attached Files:

    Last edited: Aug 18, 2021
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Unfortunately I have no idea how to make this work. The parentHwnd feature was never tested with overlapped child windows like that.
     
  18. phylomeno

    phylomeno

    Joined:
    Dec 16, 2022
    Posts:
    1
    In my case, I had a very similar problem. The Unity child window was always rendered on top of everything even if it was at the bottom with regards to Z-order.

    The solution was to create a UnityContainerWindow in which I then put the actual Unity window.

    upload_2023-3-1_6-26-56.png