修改细节

This commit is contained in:
Caiyanpeng committed 2021-04-27 19:29:22 +08:00
1 parent 1002b0433a
commit 86a5b68317
39 files changed
+3489 -2760

No files matched your search

+30 -6
View File
@@ -97,19 +97,43 @@ namespace Assets.Scripts
_toastDict = value;
}
}
private static Dictionary<string, string> _deviceDict;
public static Dictionary<string, string> deviceDict
{
get
{
if (_deviceDict == null)
{
_deviceDict = new Dictionary<string, string>
{
{"Trainer","Smart Trainer|Images/Devices/Trainer_3" },
{"Power","Power Meter|Images/Devices/Power_3" },
{"Cadence","Cadence Sensor|Images/Devices/Cadence_3" },
{"HeartRate","Heart Rate Monitor|Images/Devices/Heart Rate_3" },
{"SpeedCadence","Speed Meter|Images/Devices/Speed_3" },
};
}
return _deviceDict;
}
private set
{
_deviceDict = value;
}
}
public static void showToast(GameObject game,string text,int duration = 1,int type = 0)
{
//type 0错误 1正确
var parent = Utils.FindUpParent(game.transform);
var toast = parent.Find("ToastContainer");
if (toast == null)
if (toast != null)
{
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
newToast.name = "ToastContainer";
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newToast.transform.parent = parent;
toast = newToast.transform;
MonoBehaviour.DestroyImmediate(toast.gameObject);
}
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
newToast.name = "ToastContainer";
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newToast.transform.parent = parent;
toast = newToast.transform;
var toastStyle = toastDict[type].Split('|');
toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]);
toast.GetComponent<Image>().color = HexToColorHtml(toastStyle[1]);