Reputation: 11
I am building a Unity application (version 2019.3.12f1), embedded into a WPF host application. In the host Application, the user can switch between different tabs (one of them being the "view" --> our Unity Application). When unity Tab is "closed" it stays active in background (checked checkmark in Unity Player Settings). However, when "tabbing" back into Unity, it loses it's focus, after any mouseclick and hence won't respond to additional UI-Click events, GetMouseButton or Mouse.GetAxis("Mouse X) events. Strangely, OnMouseEnter, OnMouseExit and OnMouseDown events (over normal GameObjects) still fire the defined functions.
What I've tried so far: Importing DLL32 and using SetForegroundWindow(IntPtr hwnd); , ShowWindow(...), ShowWindowAsync(...).
Sadly I can't debug directly into unity (because it only runs as standalone version in the WPF application). So for now, all I'm doing is displaying things like Application.isFocused.ToString(); in simple Text elements.
Has anyone run into similar problems?
Upvotes: 0
Views: 182
Reputation: 11
Figured it out... WPF got stuck inside the loading event, ran into an exception but somehow didn't show it in Visual studio.
Upvotes: 1