-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale unity GUI #1152
Scale unity GUI #1152
Changes from 14 commits
2988ca7
fdbe421
c1df13e
f2d724e
215544f
02e7954
e1cb653
70e08c7
3ca1ae3
322645b
9d8225f
1c2041a
5b90e19
c75cd69
58ef28f
2eea3ab
254d1fc
ca87090
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,14 +49,14 @@ private static float BaseResolutionY { | |
public static float MaxWidth { | ||
get { | ||
float ret = Config.GuiScaleToResolution ? BaseResolutionX : Screen.width; | ||
return ret / Config.GuiScale; | ||
return ret / (Config.GuiScale * 0.01f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no magic numbers plz. make the 0.01f a variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kianzarrin I don't remember what range GuiScale is (probably 30...200+) but if it's percentage then it does not look right to me. For 100 it will return |
||
} | ||
} | ||
|
||
public static float MaxHeight { | ||
get { | ||
float ret = Config.GuiScaleToResolution ? BaseResolutionY : Screen.height; | ||
return ret / Config.GuiScale; | ||
return ret / (Config.GuiScale * 0.01f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same var |
||
} | ||
} | ||
|
||
|
@@ -70,8 +70,7 @@ public static float UIAspectScale { | |
|
||
public static float UIScale => GlobalConfig.Instance.Main.GuiScale * 0.01f; | ||
|
||
|
||
public static Matrix4x4 ScaleMatrix => Matrix4x4.Scale(Vector3.one * UIScaler.UIScale); | ||
public static Matrix4x4 ScaleMatrix => Matrix4x4.Scale(Vector3.one * UIAspectScale); | ||
|
||
public static Vector2 MousePosition { | ||
get { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ namespace TrafficManager.UI.SubTools.SpeedLimits { | |
using UnityEngine; | ||
using static TrafficManager.Util.Shortcuts; | ||
using TrafficManager.Util.Extensions; | ||
using TrafficManager.U; | ||
|
||
public class SpeedLimitsTool : LegacySubTool { | ||
public const int | ||
|
@@ -142,6 +143,8 @@ public override void OnSecondaryClickOverlay() { | |
|
||
public override void OnToolGUI(Event e) { | ||
base.OnToolGUI(e); | ||
var oldMatrix = GUI.matrix; | ||
GUI.matrix = UIScaler.ScaleMatrix; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this matrix switching thing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kk .. in that case the code is fine. |
||
|
||
string unitTitle = string.Format( | ||
" ({0})", | ||
|
@@ -176,8 +179,7 @@ public override void OnToolGUI(Event e) { | |
&& defaultsWindowRect.Contains( | ||
Event.current.mousePosition)); | ||
|
||
// overlayHandleHovered = false; | ||
// ShowSigns(false); | ||
GUI.matrix = oldMatrix; | ||
} | ||
|
||
private static NetLane[] laneBuffer => NetManager.instance.m_lanes.m_buffer; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ namespace TrafficManager.UI.SubTools.TimedTrafficLights { | |
using TrafficManager.API.TrafficLight; | ||
using TrafficManager.Manager.Impl; | ||
using TrafficManager.State; | ||
using TrafficManager.U; | ||
using TrafficManager.UI.MainMenu.OSD; | ||
using TrafficManager.UI.Textures; | ||
using TrafficManager.Util; | ||
|
@@ -308,6 +309,8 @@ public override void OnPrimaryClickOverlay() { | |
|
||
public override void OnToolGUI(Event e) { | ||
base.OnToolGUI(e); | ||
var oldMatrix = GUI.matrix; | ||
GUI.matrix = UIScaler.ScaleMatrix; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as for speedlimitstool. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all fine |
||
|
||
switch (ttlToolMode_) { | ||
case TTLToolMode.SelectNode: { | ||
|
@@ -330,6 +333,8 @@ public override void OnToolGUI(Event e) { | |
break; | ||
} | ||
} | ||
|
||
GUI.matrix = oldMatrix; | ||
} | ||
|
||
public override void RenderOverlay(RenderManager.CameraInfo cameraInfo) { | ||
|
@@ -1125,10 +1130,6 @@ private void GuiTimedTrafficLights() { | |
|
||
_cursorInSecondaryPanel = _windowRect.Contains(Event.current.mousePosition); | ||
|
||
GUI.matrix = Matrix4x4.TRS( | ||
new Vector3(0, 0, 0), | ||
Quaternion.identity, | ||
new Vector3(1, 1, 1)); // revert scaling | ||
ShowGUI(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to convert ToList() here since you don't use it as a list further down in the method.
Better to keep it a string array and use Array.FindIndex(args, a => a == "-logFile") in the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not part of this review. I updated the branch