Git Product home page Git Product logo

Comments (6)

handzlikchris avatar handzlikchris commented on September 12, 2024

Hi @VladimirMarko - thanks, glad you've found a workaround.

There shou'd be a '-' in that table.

If not you can have a look with debugger what's happening, the code that draws it is in MissingUnityEventsManagerEditorWindow :172

 if (GUILayout.Button("-", PercentageWidth(8)))
{
    _config.EventConfigurationEntries.RemoveAt(i);
}

from unity.missingunityevents.

VladimirMarko avatar VladimirMarko commented on September 12, 2024

OK, I've been playing with this and I found out that consistently PercentageWidth(66) instead of PercentageWidth(100) means the whole window width for both GUILayout and EditorGUILayout static methods/UI elements.

I had no idea why. Then I checked DPI scaling and sure enough, it was 150%. So that's the problem. The way you use width is not robust with respect to DPI scaling (at least on Windows 10).

from unity.missingunityevents.

VladimirMarko avatar VladimirMarko commented on September 12, 2024

DPI scaling = 100%:

dpi scaling 100%

DPI scaling = 150%:

dpi scaling 150%

DPI scaling = 175%:

dpi scaling 175%

from unity.missingunityevents.

VladimirMarko avatar VladimirMarko commented on September 12, 2024

Hm... I cannot figure out a clean solution to this.

The crux of the matter is that GUILayout.Button("A window-wide button", GUILayout.Width(Screen.width)); produces a button that will be wider than its window, if DPI scaling is above 100%.

We have Screen.dpi, but that's the absolute value and not a scaling factor. The base value is system-dependent (e.g., normally 96 PPI on Windows) and the Unity API does not seem to allow us to get it for the current system.

Some external packages might help, but as I understand it, Unity does not play well with the NuGet package manager, so adding them as dependencies would be non-kosher, I suspect. I am not sure about this point.

In any case, I filed a bug report with Unity, as I assume that this discrepancy in behavior between GUILayout.Width and Screen.width is unintended.

As a workaround, I would suggest defining the UI elements using just absolute pixel values. I don't know whether there is a better way.

from unity.missingunityevents.

VladimirMarko avatar VladimirMarko commented on September 12, 2024

Nevermind. I figured it out.

Apparently the correct thing to use is position.width (inherited from EditorWindow), instead of Screen.width.

I will submit a pull request.

from unity.missingunityevents.

handzlikchris avatar handzlikchris commented on September 12, 2024

Thanks @VladimirMarko that's some good investigation and fix

from unity.missingunityevents.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.