Author Topic: Direct3D9 resolution switch hides UI  (Read 8876 times)

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Direct3D9 resolution switch hides UI
« on: September 05, 2016, 05:18:15 AM »
Hi all!

I'm in the middle of improving the Settings screen for my game, which includes the functionality to change the resolution.
I'm pretty sure that we never had this problem with older builds of my game, which had older NGUI versions:

When the resolution is changed, the UI is gone!
It still seems to catch button events, but it does not render.
(luckily, when I escape the screen to go back to my main menu it renders okay again).

I created a test exe build using the NGUI example project, and it also happens there.
The problem occurs under Direct3D9 (both Exclusive and Fullscreen window).
It does NOT occur under Direct3D11 (which in most cases would be auto selected).

The tempory fix seems to be to create a co-routine to wait for the resolution change to have taken effect, and then use SetActive(false) and then (true) on all UIPanel GameObject that you need.
Doing stuff with the camera component, UIPanel components or RebuildAllDrawCalls had no effect.

>>> Question: Is this a known issue and will it be resolved?
>>> Question: Is there anything else I could use to force some sort of reset or redraw? The disabling/enabling of objects is not a good solution for me.

Diederik / Xform

P.S. I'm using NGUI 3.10
« Last Edit: September 05, 2016, 06:41:14 AM by diederik »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #1 on: September 05, 2016, 08:33:34 AM »
This is not an known issue. Windward is a DX9 game, and you can change the screen resolution from within the game. It works as expected. Granted, it was built with Unity 4.7 not Unity 5... but I don't think it should matter. Can you create a simple repro case for me to have a look at that shows this issue?

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #2 on: September 06, 2016, 05:53:47 AM »
Hi ArenMook,

I posted a video capture of the problem here:
https://youtu.be/JPocf5ioLlE
(currently processing video)
I hope this gives you enough information.

Looking forward to your thoughts on this.
As I mentioned, please advise me if there are other things I could try to (temporarily) fix it, withouth enabling/disabling gameobjects!

Diederik / Xform

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #3 on: September 09, 2016, 02:12:01 PM »
Sounds like a possible Unity bug. Can you reproduce the same issue with just one of NGUI's example and a simple resolution switching script? Because I can't... Did a DX9 build of the Example 0 with this script attached:
  1. using UnityEngine;
  2.  
  3. public class ResChange : MonoBehaviour
  4. {
  5.         void Update ()
  6.         {
  7.                 if (Input.GetKeyDown(KeyCode.Alpha1))
  8.                 {
  9.                         Screen.SetResolution(1920, 1080, true);
  10.                 }
  11.                 else if (Input.GetKeyDown(KeyCode.Alpha2))
  12.                 {
  13.                         Screen.SetResolution(1280, 720, true);
  14.                 }
  15.                 else if (Input.GetKeyDown(KeyCode.Alpha3))
  16.                 {
  17.                         Screen.SetResolution(3440, 1440, true);
  18.                 }
  19.         }
  20. }
  21.  
Everything works as expected. The UI is always visible.

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #4 on: September 10, 2016, 03:09:47 PM »
Hi Arenmook,

Thanks for looking into this. Although maybe a bit to briefly?
You are right that Example 0 has no problems!
But I soon encountered them in Example 2 en 3 :(.
Of course, as you know, Example 0 has no UIPanels ;).

I added a panel in between the root and the rest. Still no problems.
Then I added another new panel with a new sprite, and stuff started going wrong.
It sometimes takes multiple resolution changes for the problem to occur though. And sometimes one of multiple panels breaks down first. (But, indeed, in Example 2 it occured on the very first switch for me).

For me it is very easy to recreate though.
* New scene
* New 2D UI (Add the reschange script!)
* Add Panel
* Add Sprite.
* Build (DX9).

> Can you to recreate it this way for me? From a new scene and interface?

Sorry that I do not have better news.

Diederik /Xform

P.S. For my testing i changed the resolutions to ones my display supported in your example script (which I attachted to the UIRoot).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #5 on: September 13, 2016, 10:50:10 AM »
Yup, seems Unity broke something on their end.

You can fix it by commenting out line 453 of UIDrawCall:
  1. //mMesh.MarkDynamic();

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #6 on: September 15, 2016, 01:55:53 AM »
Hi Arenmook,

I'll give it a try (fingers crossed that it doesn't break something different ;))

We've been working on this current game over the passed couple of years now, and we too had our fair share of Unity (and NGUI ;)) updatest breaking stuff.

Keep up the good work!

Diederik / Xform

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Direct3D9 resolution switch hides UI
« Reply #7 on: September 15, 2016, 04:07:33 AM »
i've had a similar problem.  when returning from screensaver mode the UI is often gone.

not sure if it is random, and i have not had time to track the issue yet.