using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Networking; using System.Text.RegularExpressions; using System.Data.SqlClient; using TMPro; using System; using System.IO; using ZXing; using ZXing.QrCode; using System.Net; using SimpleJSON; using System.ComponentModel; using System.Runtime.InteropServices; public class 配方製成表 : MonoBehaviour { [SerializeField] TextMeshProUGUI 比例; [SerializeField] TextMeshProUGUI 溫度; [SerializeField] TextMeshProUGUI 時間; [SerializeField] TextMeshProUGUI 淨重; [SerializeField] TextMeshProUGUI 單位; [SerializeField] TextMeshProUGUI 包材; [SerializeField] TextMeshProUGUI 打包; [SerializeField] TextMeshProUGUI 條件; [SerializeField] TextMeshProUGUI 期限; [SerializeField] TextMeshProUGUI 有效; [SerializeField] TextMeshProUGUI 過敏; public GameObject buttonPrefab1; public Transform buttonParent1; public GameObject buttonceneter1; private List copy1 = new List(); public GameObject buttonPrefab2; public Transform buttonParent2; public GameObject buttonceneter2; private List copy2 = new List(); public GameObject buttonPrefab3; public Transform buttonParent3; public GameObject buttonceneter3; private List copy3 = new List(); public GameObject buttonPrefab4; public Transform buttonParent4; public GameObject buttonceneter4; private List copy4 = new List(); public GameObject buttonPrefab5; public Transform buttonParent5; public GameObject buttonceneter5; private List copy5 = new List(); public GameObject buttonPrefab6; public Transform buttonParent6; public GameObject buttonceneter6; private List copy6 = new List(); public GameObject buttonPrefab7; public Transform buttonParent7; public GameObject buttonceneter7; private List copy7 = new List(); public GameObject buttonPrefab8; public Transform buttonParent8; public GameObject buttonceneter8; private List copy8 = new List(); [SerializeField] TextMeshProUGUI 原料小計1; [SerializeField] TextMeshProUGUI 原料小計2; [SerializeField] TextMeshProUGUI 原料小計3; [SerializeField] TextMeshProUGUI 乳化小計1; [SerializeField] TextMeshProUGUI 乳化小計2; [SerializeField] TextMeshProUGUI 香料小計1; [SerializeField] TextMeshProUGUI 香料小計2; [SerializeField] TextMeshProUGUI 其他小計1; [SerializeField] TextMeshProUGUI 其他小計2; [SerializeField] TextMeshProUGUI 著色小計1; [SerializeField] TextMeshProUGUI 著色小計2; [SerializeField] TextMeshProUGUI 合計產品; [SerializeField] TextMeshProUGUI 合計產品重量; [SerializeField] RawImage 已核准; [SerializeField] RawImage 已發行; public Sprite 紅燈; public Sprite 綠燈; [SerializeField] TextMeshProUGUI 名稱; [SerializeField] TextMeshProUGUI 編號; [SerializeField] TextMeshProUGUI 種類; [SerializeField] TextMeshProUGUI 噸數; [SerializeField] TextMeshProUGUI 季節; [SerializeField] TextMeshProUGUI 版本; [SerializeField] TextMeshProUGUI 標章; [SerializeField] TextMeshProUGUI 日期; [SerializeField] TextMeshProUGUI 出貨; [SerializeField] TextMeshProUGUI 備註; [SerializeField] Toggle 代工; [SerializeField] GameObject 清單; [SerializeField] GameObject 明細; public GameObject buttonPrefab; public Transform buttonParent; public GameObject buttonceneter; private List copy = new List(); double 產品和; double 重量和; public CanvasScaler canvasScaler; private string loadingText = ""; private int dotCount = 0; [SerializeField] GameObject 讀取面板; [SerializeField] TextMeshProUGUI 讀取; [SerializeField] GameObject 彈跳面板; [SerializeField] TextMeshProUGUI 彈跳文字; // Start is called before the first frame update void Start() { Screen.autorotateToPortrait = false; Screen.orientation = ScreenOrientation.LandscapeLeft; float rate = 1600.0f / 1000.0f; if (Main.Global.rate>rate) { canvasScaler.matchWidthOrHeight = 1f; } else { canvasScaler.matchWidthOrHeight = 0f; } //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/ow_main.php?"; //Main.Global.預設伺服器路徑="official"; 清單.SetActive(true); 明細.SetActive(false); StartCoroutine(AnimateText()); StartCoroutine(油脂種類下拉清單()); } public void 截圖() { string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss")); ScreenCapture.CaptureScreenshot(fileName); } IEnumerator AnimateText() { string qqq = 讀取.text.ToString(); while (true) { yield return new WaitForSeconds(0.5f); if (dotCount < 3) { loadingText += "."; dotCount++; } else { loadingText = ""; dotCount = 0; } 讀取.text = qqq+loadingText; } } IEnumerator 油脂種類下拉清單() { 讀取面板.SetActive(true); if (copy8 != null) { DeleteCopies(copy8); } string strcon = "油脂種類下拉清單"; string se = Main.Global.預設伺服器路徑; string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se); UnityWebRequest request = UnityWebRequest.Get(strUrl); Debug.Log(strUrl); yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.ConnectionError) { Debug.Log(request.error); yield break; } JSONNode json = JSON.Parse(request.downloadHandler.text); Debug.Log(json); int sum = 5; GameObject selectedButton = null; for (int i = 0; i < json.Count; i++) { GameObject buttonObj = Instantiate(buttonPrefab8) as GameObject; buttonObj.GetComponent().anchoredPosition = new Vector2(2, -sum); buttonObj.transform.SetParent(buttonParent8, false); TextMeshProUGUI text = buttonObj.GetComponentInChildren(); Button bt = buttonObj.GetComponentInChildren