划船机其他细节
This commit is contained in:
1 parent
a4e17a56d0
commit
eb21914fb7
8 files changed
+1949
-1667
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -28,15 +29,18 @@ public class Toast : MonoBehaviour
|
||||
[SerializeField] GameObject toast;
|
||||
[SerializeField] Text txt;
|
||||
|
||||
public void showToast(string json)
|
||||
public void showToast(Assets.Scripts.Utils.ToastParams json)
|
||||
{
|
||||
JObject JO = (JObject)JsonConvert.DeserializeObject(json);
|
||||
gameObject.SetActive(true);
|
||||
StartCoroutine(showToastCOR(JO.Value<string>("text"), JO.Value<int>("duration")));
|
||||
if (json.func == null)
|
||||
{
|
||||
json.func = () => false;
|
||||
}
|
||||
StartCoroutine(showToastCOR(json.text, json.duration,json.func));
|
||||
}
|
||||
|
||||
private IEnumerator showToastCOR(string text,
|
||||
int duration)
|
||||
int duration, Func<bool> action)
|
||||
{
|
||||
|
||||
gameObject.SetActive(true);
|
||||
@@ -46,7 +50,7 @@ public class Toast : MonoBehaviour
|
||||
|
||||
//Wait for the duration
|
||||
float counter = 0;
|
||||
while (counter < duration)
|
||||
while (counter < duration && !action.Invoke())
|
||||
{
|
||||
counter += Time.deltaTime;
|
||||
yield return null;
|
||||
|
||||
@@ -143,13 +143,13 @@ namespace Assets.Scripts
|
||||
_deviceDict = value;
|
||||
}
|
||||
}
|
||||
public static void showToast(GameObject game,string text,int duration = 2,int type = 0)
|
||||
public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false)
|
||||
{
|
||||
//type 0错误 1正确
|
||||
var parent = UIManager.Instance.ModalsPanel;
|
||||
if (parent == null) return;
|
||||
var toast = parent.transform.Find("ToastContainer");
|
||||
if (toast != null)
|
||||
if (toast != null)
|
||||
{
|
||||
MonoBehaviour.DestroyImmediate(toast.gameObject);
|
||||
}
|
||||
@@ -163,13 +163,28 @@ namespace Assets.Scripts
|
||||
newToast.transform.parent = parent.transform;
|
||||
toast = newToast.transform;
|
||||
var toastStyle = toastDict[type].Split('|');
|
||||
if (isLowest)
|
||||
{
|
||||
toast.SetAsFirstSibling();
|
||||
}
|
||||
else
|
||||
{
|
||||
toast.SetAsLastSibling();
|
||||
}
|
||||
toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]);
|
||||
toast.GetComponent<Image>().color = HexToColorHtml(toastStyle[1]);
|
||||
toast.GetComponent<Toast>().showToast(JsonConvert.SerializeObject(new
|
||||
toast.GetComponent<Toast>().showToast(new ToastParams
|
||||
{
|
||||
text,
|
||||
duration
|
||||
}));
|
||||
text = text,
|
||||
duration = duration,
|
||||
func = stopFunc
|
||||
});
|
||||
}
|
||||
public class ToastParams
|
||||
{
|
||||
public string text { get; set; }
|
||||
public int duration { get; set; }
|
||||
public Func<bool> func { get; set; }
|
||||
}
|
||||
/*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/
|
||||
public static void showLoading(this GameObject game)
|
||||
|
||||
Reference in new issue
Block a user