Skip to content

Commit 380226d

Browse files
committed
# Conflicts: # Assets/ModalWindows/Scripts/ModalWindows/InputModalWindow.cs
2 parents 0f038c6 + 749463a commit 380226d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

Assets/ModalWindows/Scripts/ModalWindow.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public virtual T SetHeader(string text)
9292

9393
return Instance;
9494
}
95+
96+
9597

9698
public virtual T SetBody(string text)
9799
{
@@ -119,6 +121,23 @@ protected virtual void OnBeforeShow()
119121
}
120122
}
121123

124+
protected virtual void Update()
125+
{
126+
CheckIgnorableForClose();
127+
}
128+
129+
protected virtual void CheckIgnorableForClose()
130+
{
131+
if (Input.GetKeyDown(KeyCode.Escape))
132+
{
133+
if (!ReferenceEquals(Instance, null))
134+
{
135+
if (Instance.ignorable)
136+
Instance.Close();
137+
}
138+
}
139+
}
140+
122141
public virtual T Show()
123142
{
124143
OnBeforeShow();

Assets/ModalWindows/Scripts/ModalWindows/InputModalWindow.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ void SubmitInput()
3131
Close();
3232
}
3333

34-
protected void Update()
34+
protected override void Update()
3535
{
36+
base.Update();
3637
if (inputField.isFocused && inputField.text != "" && Input.GetKeyUp(KeyCode.Return))
37-
{
3838
SubmitInput();
39-
}
4039
}
4140

4241
public void UI_InputFieldOKButton()

Assets/ModalWindows/Scripts/ModalWindows/SimpleModalWindow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections;
1+
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using UnityEngine;
45

@@ -8,4 +9,5 @@ public class SimpleModalWindow : ModalWindow<SimpleModalWindow>
89
{
910
return ModalWindow<SimpleModalWindow>.Create(ignorable);
1011
}
12+
1113
}

0 commit comments

Comments
 (0)