From ba324aa68d67afb351504f7c7f79e403afd81b73 Mon Sep 17 00:00:00 2001 From: CaiYanPeng Date: Thu, 25 Mar 2021 17:18:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=9C=BA=E6=99=AF=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI}/Prefab/MainFuncContainer.prefab | 0 .../UI}/Prefab/MainFuncContainer.prefab.meta | 0 .../UI}/Prefab/MainToolContainer.prefab | 0 .../UI}/Prefab/MainToolContainer.prefab.meta | 0 .../UI}/Prefab/UserInfo.prefab | 0 .../UI}/Prefab/UserInfo.prefab.meta | 0 Assets/{Cyp => Scenes}/2-Main.unity | 5 ++ Assets/{Cyp => Scenes}/2-Main.unity.meta | 0 Assets/Scripts/ConfigHelper.cs | 8 ++- Assets/{Cyp => Scripts/UI}/Prefab/UserInfo.cs | 8 +-- .../UI}/Prefab/UserInfo.cs.meta | 0 Assets/{Cyp/Common => Scripts/Utils}/Toast.cs | 0 .../Common => Scripts/Utils}/Toast.cs.meta | 0 Assets/Scripts/Utils/Utils.cs | 59 +++++++++++++++++++ Assets/Scripts/Utils/Utils.cs.meta | 11 ++++ Assets/StreamingAssets.meta | 8 --- Packages/manifest.json | 1 + Packages/packages-lock.json | 7 +++ 18 files changed, 94 insertions(+), 13 deletions(-) rename Assets/{Cyp => Resources/UI}/Prefab/MainFuncContainer.prefab (100%) rename Assets/{Cyp => Resources/UI}/Prefab/MainFuncContainer.prefab.meta (100%) rename Assets/{Cyp => Resources/UI}/Prefab/MainToolContainer.prefab (100%) rename Assets/{Cyp => Resources/UI}/Prefab/MainToolContainer.prefab.meta (100%) rename Assets/{Cyp => Resources/UI}/Prefab/UserInfo.prefab (100%) rename Assets/{Cyp => Resources/UI}/Prefab/UserInfo.prefab.meta (100%) rename Assets/{Cyp => Scenes}/2-Main.unity (99%) rename Assets/{Cyp => Scenes}/2-Main.unity.meta (100%) rename Assets/{Cyp => Scripts/UI}/Prefab/UserInfo.cs (93%) rename Assets/{Cyp => Scripts/UI}/Prefab/UserInfo.cs.meta (100%) rename Assets/{Cyp/Common => Scripts/Utils}/Toast.cs (100%) rename Assets/{Cyp/Common => Scripts/Utils}/Toast.cs.meta (100%) create mode 100644 Assets/Scripts/Utils/Utils.cs create mode 100644 Assets/Scripts/Utils/Utils.cs.meta delete mode 100644 Assets/StreamingAssets.meta diff --git a/Assets/Cyp/Prefab/MainFuncContainer.prefab b/Assets/Resources/UI/Prefab/MainFuncContainer.prefab similarity index 100% rename from Assets/Cyp/Prefab/MainFuncContainer.prefab rename to Assets/Resources/UI/Prefab/MainFuncContainer.prefab diff --git a/Assets/Cyp/Prefab/MainFuncContainer.prefab.meta b/Assets/Resources/UI/Prefab/MainFuncContainer.prefab.meta similarity index 100% rename from Assets/Cyp/Prefab/MainFuncContainer.prefab.meta rename to Assets/Resources/UI/Prefab/MainFuncContainer.prefab.meta diff --git a/Assets/Cyp/Prefab/MainToolContainer.prefab b/Assets/Resources/UI/Prefab/MainToolContainer.prefab similarity index 100% rename from Assets/Cyp/Prefab/MainToolContainer.prefab rename to Assets/Resources/UI/Prefab/MainToolContainer.prefab diff --git a/Assets/Cyp/Prefab/MainToolContainer.prefab.meta b/Assets/Resources/UI/Prefab/MainToolContainer.prefab.meta similarity index 100% rename from Assets/Cyp/Prefab/MainToolContainer.prefab.meta rename to Assets/Resources/UI/Prefab/MainToolContainer.prefab.meta diff --git a/Assets/Cyp/Prefab/UserInfo.prefab b/Assets/Resources/UI/Prefab/UserInfo.prefab similarity index 100% rename from Assets/Cyp/Prefab/UserInfo.prefab rename to Assets/Resources/UI/Prefab/UserInfo.prefab diff --git a/Assets/Cyp/Prefab/UserInfo.prefab.meta b/Assets/Resources/UI/Prefab/UserInfo.prefab.meta similarity index 100% rename from Assets/Cyp/Prefab/UserInfo.prefab.meta rename to Assets/Resources/UI/Prefab/UserInfo.prefab.meta diff --git a/Assets/Cyp/2-Main.unity b/Assets/Scenes/2-Main.unity similarity index 99% rename from Assets/Cyp/2-Main.unity rename to Assets/Scenes/2-Main.unity index 30ad2018..8c2f1a36 100644 --- a/Assets/Cyp/2-Main.unity +++ b/Assets/Scenes/2-Main.unity @@ -504,6 +504,11 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1180902778} m_Modifications: + - target: {fileID: 2589794477215490372, guid: 652cdefe0475dfd429e5a7e92bc3fa31, + type: 3} + propertyPath: m_DownSamplingRate + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2589794478191162464, guid: 652cdefe0475dfd429e5a7e92bc3fa31, type: 3} propertyPath: m_Name diff --git a/Assets/Cyp/2-Main.unity.meta b/Assets/Scenes/2-Main.unity.meta similarity index 100% rename from Assets/Cyp/2-Main.unity.meta rename to Assets/Scenes/2-Main.unity.meta diff --git a/Assets/Scripts/ConfigHelper.cs b/Assets/Scripts/ConfigHelper.cs index ec756be6..03e6d02c 100644 --- a/Assets/Scripts/ConfigHelper.cs +++ b/Assets/Scripts/ConfigHelper.cs @@ -1,4 +1,6 @@ -using System; +using Assets.Scripts.Apis; +using Assets.Scripts.Apis.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,5 +13,9 @@ namespace Assets.Scripts public static string Host = App.Host; public static string AppVersion = App.AppVersion; + public static UserResultModel CurrentUser { get; set; } + public static UserApi userApi = new UserApi(); + public static MapApi mapApi = new MapApi(); + public static MapInterruptRecordApi mapInterruptRecordApi = new MapInterruptRecordApi(); } } diff --git a/Assets/Cyp/Prefab/UserInfo.cs b/Assets/Scripts/UI/Prefab/UserInfo.cs similarity index 93% rename from Assets/Cyp/Prefab/UserInfo.cs rename to Assets/Scripts/UI/Prefab/UserInfo.cs index 00e94f76..3840a0e0 100644 --- a/Assets/Cyp/Prefab/UserInfo.cs +++ b/Assets/Scripts/UI/Prefab/UserInfo.cs @@ -1,4 +1,4 @@ -using Assets.Cyp.Common; +using Assets.Scripts; using System; using System.Collections; using System.Collections.Generic; @@ -27,7 +27,7 @@ public class UserInfo : MonoBehaviour toast.GetComponent().position = new Vector3(Screen.width / 2, Screen.height / 2, 0); toast.transform.parent = parent; } - if (Global.CurrentUser != null) + if (ConfigHelper.CurrentUser != null) { SetCurrentUser(); GetSummary(); @@ -45,7 +45,7 @@ public class UserInfo : MonoBehaviour void SetCurrentUser() { - var user = Global.CurrentUser; + var user = ConfigHelper.CurrentUser; Ftp.text = user.FTP.ToString(); Weight.text = user.Weight.ToString(); WKG.text = $"{user.Weight}KG/{user.BicycleWeight}KG"; @@ -54,7 +54,7 @@ public class UserInfo : MonoBehaviour } void GetSummary() { - var res = Global.userApi.GetSummary(); + var res = ConfigHelper.userApi.GetSummary(); if (res.result) { KM.text = $"{res.data.TotalDistance.ToString("#0.00")}KM"; diff --git a/Assets/Cyp/Prefab/UserInfo.cs.meta b/Assets/Scripts/UI/Prefab/UserInfo.cs.meta similarity index 100% rename from Assets/Cyp/Prefab/UserInfo.cs.meta rename to Assets/Scripts/UI/Prefab/UserInfo.cs.meta diff --git a/Assets/Cyp/Common/Toast.cs b/Assets/Scripts/Utils/Toast.cs similarity index 100% rename from Assets/Cyp/Common/Toast.cs rename to Assets/Scripts/Utils/Toast.cs diff --git a/Assets/Cyp/Common/Toast.cs.meta b/Assets/Scripts/Utils/Toast.cs.meta similarity index 100% rename from Assets/Cyp/Common/Toast.cs.meta rename to Assets/Scripts/Utils/Toast.cs.meta diff --git a/Assets/Scripts/Utils/Utils.cs b/Assets/Scripts/Utils/Utils.cs new file mode 100644 index 00000000..487f3c36 --- /dev/null +++ b/Assets/Scripts/Utils/Utils.cs @@ -0,0 +1,59 @@ +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.Networking; +using UnityEngine.UI; + +namespace Assets.Scripts +{ + public static class Utils + { + /*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/ + public static void showToast(GameObject game,string text,int duration = 1) + { + var toast = Utils.FindUpParent(game.transform).Find("ToastContainer"); + if (toast!=null) + { + toast.GetComponent().showToast(JsonConvert.SerializeObject(new + { + text, + duration + })); + //toast.SendMessage("showToast", ); + } + } + /*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/ + + /*显示网络图片*/ + public delegate Coroutine StartCoroutine(IEnumerator routine); + public static void DisplayImage(StartCoroutine startCoroutine,RawImage img, string url) + { + startCoroutine(DownloadImage(img, url)); + } + static IEnumerator DownloadImage(RawImage img,string MediaUrl) + { + UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl); + yield return request.SendWebRequest(); + if (request.isNetworkError || request.isHttpError) + Debug.Log(request.error); + else + img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture; + } + /*显示网络图片*/ + + /*获取最顶层对象*/ + public static Transform FindUpParent(Transform zi) + { + if (zi.parent == null) + return zi; + else + return FindUpParent(zi.parent); + } + /*获取最顶层对象*/ + } +} diff --git a/Assets/Scripts/Utils/Utils.cs.meta b/Assets/Scripts/Utils/Utils.cs.meta new file mode 100644 index 00000000..b933872b --- /dev/null +++ b/Assets/Scripts/Utils/Utils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 860b65f14906bba44b260c0fec18bca6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets.meta b/Assets/StreamingAssets.meta deleted file mode 100644 index 0cbd8580..00000000 --- a/Assets/StreamingAssets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9a0a7989900f2c34abeee17c663d08dc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 14f5d217..89b5b109 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git", "com.unity.collab-proxy": "1.2.16", "com.unity.ide.rider": "1.1.4", "com.unity.ide.vscode": "1.2.3", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 9cf53f75..36e8bcc3 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,5 +1,12 @@ { "dependencies": { + "com.coffee.softmask-for-ugui": { + "version": "https://github.com/mob-sakai/SoftMaskForUGUI.git", + "depth": 0, + "source": "git", + "dependencies": {}, + "hash": "f59d147fe04be6a84b3cd7eb93bce149410911be" + }, "com.unity.collab-proxy": { "version": "1.2.16", "depth": 0,