using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Networking; using UnityEngine.EventSystems; using System.Text.RegularExpressions; using System.Data.SqlClient; using System.Runtime.InteropServices; using System.Text; using TMPro; using System; using System.IO; using ZXing; using ZXing.QrCode; using System.Net; using System.Data; using SimpleJSON; using System.Linq; using System.ComponentModel; using System.Runtime.InteropServices; using System.Globalization; using XCharts.Runtime; public class 庫存盤營盤損 : MonoBehaviour { [SerializeField] Toggle 非零切換; [SerializeField] Toggle 零切換; [SerializeField] GameObject 非零清單面板; [SerializeField] GameObject 零清單面板; private JSONNode 非零清單; private JSONNode 零清單; private JSONNode 非零清單計算; private JSONNode 零清單計算; public GameObject buttonPrefab; public Transform buttonParent; public GameObject buttonceneter; private List copy = new List(); public GameObject buttonPrefab1; public Transform buttonParent1; public GameObject buttonceneter1; private List copy1 = new List(); public CanvasScaler canvasScaler; [SerializeField] GameObject 讀取面板; [SerializeField] TextMeshProUGUI 讀取; [SerializeField] GameObject 彈跳面板; [SerializeField] TextMeshProUGUI 彈跳文字; private string loadingText = ""; private int dotCount = 0; private int itemsPerPage = 17; private int currentPage = 0; private int currentPage1 = 0; // Start is called before the first frame update void Start() { Screen.autorotateToPortrait = false; Screen.orientation = ScreenOrientation.Portrait; float rate = 1000.0f / 1600.0f; if (canvasScaler == null) { canvasScaler = GetComponent(); } if (Main.Global.rate>rate) { canvasScaler.matchWidthOrHeight = 1f; } else { canvasScaler.matchWidthOrHeight = 0f; } StartCoroutine(AnimateText()); //Main.Global.人員="李協叡"; //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/GF_main.php?"; //Main.Global.預設伺服器路徑="GF99"; 非零切換.isOn = true; 零切換.isOn = false; 非零清單面板.SetActive(true); 零清單面板.SetActive(false); StartCoroutine(庫存盤營盤損1()); } public void 非零_click() { if (非零切換.isOn==false && 零切換.isOn==false) { 非零切換.isOn = true; 零切換.isOn = false; } else if (非零切換.isOn==true && 零切換.isOn==true) { 非零切換.isOn = true; 零切換.isOn = false; 非零清單面板.SetActive(true); 零清單面板.SetActive(false); } } public void 零_click() { if (非零切換.isOn==false && 零切換.isOn==false) { 非零切換.isOn = false; 零切換.isOn = true; } else if (非零切換.isOn==true && 零切換.isOn==true) { 非零切換.isOn = false; 零切換.isOn = true; 非零清單面板.SetActive(false); 零清單面板.SetActive(true); } } 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 庫存盤營盤損1() { 讀取面板.SetActive(true); string strcon = "庫存盤營盤損"; string se = Main.Global.預設伺服器路徑; string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se); UnityWebRequest request = UnityWebRequest.Get(strUrl); yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.ConnectionError) { Debug.Log(request.error); yield break; } 非零清單 = JSON.Parse(request.downloadHandler.text); 非零清單計算 = JSON.Parse(request.downloadHandler.text); yield return StartCoroutine(庫存盤營盤損2()); } IEnumerator 庫存盤營盤損2() { string strcon = "庫存盤營盤損1"; string se = Main.Global.預設伺服器路徑; string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se); UnityWebRequest request = UnityWebRequest.Get(strUrl); yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.ConnectionError) { Debug.Log(request.error); yield break; } 零清單 = JSON.Parse(request.downloadHandler.text); 零清單計算 = JSON.Parse(request.downloadHandler.text); 非零(); 零(); 讀取面板.SetActive(false); } private void 非零() { if (copy != null) { DeleteCopies(copy); } int startIndex = currentPage * itemsPerPage; int endIndex = Mathf.Min((currentPage + 1) * itemsPerPage, 非零清單.Count); int sum = 2; for (int i = startIndex; i < endIndex; i++) { GameObject buttonObj = Instantiate(buttonPrefab) as GameObject; buttonObj.GetComponent().anchoredPosition = new Vector2(2, -sum); buttonObj.transform.SetParent(buttonParent, false); TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren(); TMP_InputField text1 = buttonObj.GetComponentInChildren(); Button[] bt = buttonObj.GetComponentsInChildren