Skip to content

Commit

Permalink
Stop changing props menu during modify scale factor
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang committed Dec 5, 2023
1 parent b44211f commit 0541f54
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 3 additions & 5 deletions Assets/Scripts/UI/SimulationDisplay.Props.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public partial class SimulationDisplay : MonoBehaviour
private bool checkScaleFactorFocused = false;
private bool doCheckScaleFactorValue = false;
private RectOffset zeroPadding;

private void InitPropsMenu()
{
// toolbarStrings = new string[] { "Box", "Cylinder", "Sphere" };
}
private bool isChangingScaleFactor = false;

private void DrawPropsMenus()
{
Expand Down Expand Up @@ -59,6 +55,8 @@ private void DrawPropsMenus()
GUI.skin.textField.alignment = TextAnchor.MiddleCenter;
scaleFactorString = GUI.TextField(rectScale, scaleFactorString, 5);

isChangingScaleFactor = (GUI.GetNameOfFocusedControl().CompareTo("ScaleField") == 0);

rectHelpButton.x = rectScale.x + rectScale.width + textRightMargin;

if (checkScaleFactorFocused && !GUI.GetNameOfFocusedControl().Equals("ScaleField"))
Expand Down
28 changes: 15 additions & 13 deletions Assets/Scripts/UI/SimulationDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void Awake()
padding = new RectOffset(30, 30, 30, 30);
zeroPadding = new RectOffset(0, 0, 0, 0);

InitPropsMenu();
UpdateHelpContents();
}

Expand Down Expand Up @@ -179,27 +178,30 @@ void OnGUI()
if (Event.current.type.Equals(EventType.KeyUp))
{
var keyCode = Event.current.keyCode;
if (keyCode.CompareTo(KeyCode.F1) == 0)
if (keyCode == KeyCode.F1)
{
popupHelpDialog = !popupHelpDialog;
cameraControl.BlockMouseWheelControl(true);
}
else if (keyCode.CompareTo(KeyCode.Escape) == 0)
else if (keyCode == KeyCode.Escape)
{
popupHelpDialog = false;
cameraControl.BlockMouseWheelControl(false);
}
else if (keyCode.CompareTo(KeyCode.Alpha1) == 0)
else if (keyCode >= KeyCode.Alpha1 && keyCode <= KeyCode.Alpha9 && isChangingScaleFactor == false)
{
_toolbarSelected = 0;
}
else if (keyCode.CompareTo(KeyCode.Alpha2) == 0)
{
_toolbarSelected = 1;
}
else if (keyCode.CompareTo(KeyCode.Alpha3) == 0)
{
_toolbarSelected = 2;
switch (keyCode)
{
case KeyCode.Alpha1:
_toolbarSelected = 0;
break;
case KeyCode.Alpha2:
_toolbarSelected = 1;
break;
case KeyCode.Alpha3:
_toolbarSelected = 2;
break;
}
}
}

Expand Down

0 comments on commit 0541f54

Please sign in to comment.