划船机保存前读秒
This commit is contained in:
1 parent
eb21914fb7
commit
b9aa0131cc
5 files changed
+4348
-4324
No files matched your search
@@ -36,23 +36,40 @@ public class Toast : MonoBehaviour
|
||||
{
|
||||
json.func = () => false;
|
||||
}
|
||||
StartCoroutine(showToastCOR(json.text, json.duration,json.func));
|
||||
StartCoroutine(showToastCOR(json.text, json.duration,json.func,json.showSeconds));
|
||||
}
|
||||
|
||||
private IEnumerator showToastCOR(string text,
|
||||
int duration, Func<bool> action)
|
||||
int duration, Func<bool> action,bool showSeconds)
|
||||
{
|
||||
|
||||
gameObject.SetActive(true);
|
||||
txt.text = text;
|
||||
if (showSeconds)
|
||||
{
|
||||
txt.text = text + $"({duration}s)";
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = text;
|
||||
}
|
||||
//Fade in
|
||||
yield return fadeInAndOut(txt, true, 0.5f);
|
||||
|
||||
//Wait for the duration
|
||||
float counter = 0;
|
||||
float counter = 0,timer = 1f;
|
||||
int seconds = 0;
|
||||
while (counter < duration && !action.Invoke())
|
||||
{
|
||||
counter += Time.deltaTime;
|
||||
if (showSeconds)
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer < 0)
|
||||
{
|
||||
txt.text = text + $"({duration - (++seconds)}s)";
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Assets.Scripts
|
||||
_deviceDict = value;
|
||||
}
|
||||
}
|
||||
public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false)
|
||||
public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false)
|
||||
{
|
||||
//type 0错误 1正确
|
||||
var parent = UIManager.Instance.ModalsPanel;
|
||||
@@ -177,11 +177,13 @@ namespace Assets.Scripts
|
||||
{
|
||||
text = text,
|
||||
duration = duration,
|
||||
func = stopFunc
|
||||
func = stopFunc,
|
||||
showSeconds = showSeconds
|
||||
});
|
||||
}
|
||||
public class ToastParams
|
||||
{
|
||||
public bool showSeconds { get; set; }
|
||||
public string text { get; set; }
|
||||
public int duration { get; set; }
|
||||
public Func<bool> func { get; set; }
|
||||
|
||||
Reference in new issue
Block a user