Search Unity

OnGUI Inspector Displays Differently on Second Monitor

Discussion in 'Immediate Mode GUI (IMGUI)' started by boehmzViacommix, Jun 21, 2019.

  1. boehmzViacommix

    boehmzViacommix

    Joined:
    May 4, 2017
    Posts:
    16
    I am displaying a bool as two buttons that the user can toggle between in the inspector. I indicate the current chosen value by drawing the button's normal state as if it is pressed. This works as expected when my Unity window is on my main monitor. However, if I drag my Unity window to the second monitor the inspector's look changes.

    I don't change anything when going back and forth between the monitors, it simply works on the main monitor but not on any extra monitor. This appears to only happen for scaledBackgrounds. If I change GUI.skin.button.normal.textColor it works on all monitors.

    The code is like so:
    Code (CSharp):
    1. static Texture2D[] pressedButtonBgImages;
    2.  
    3. public override void OnInspectorGUI () {
    4.     if (pressedButtonBgImages == null)
    5.     {
    6.         pressedButtonBgImages = new Texture2D[1];
    7.         pressedButtonBgImages[0] = GUI.skin.button.active.scaledBackgrounds[0];
    8.     }
    9.     Texture2D[] cachedNormalButtonBgImages = GUI.skin.button.normal.scaledBackgrounds;
    10.     if (alwaysDrawPressed)
    11.      {
    12.             GUI.skin.button.normal.scaledBackgrounds = pressedButtonBgImages;
    13.             GUILayout.Button(trueLabel);
    14.     }
    15. }
    16.  
    I am Unity 2018.3 on macOS Sierra
     

    Attached Files:

  2. IC_

    IC_

    Joined:
    Jan 27, 2016
    Posts:
    31
    Unity UI poorness
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    6,396
    What's your platform and what are the two monitors? For example, if you're dragging it between a Retina display and a 1080p TV, I imagine the Editor will alter the way it draws UI elements so as not to make your eyes bleed.