using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using UnityEngine.Networking; using Button = UnityEngine.UI.Button; using UnityEngine.EventSystems; //using Unity.VisualScripting.Dependencies.Sqlite; [RequireComponent(typeof(Button))] public class SaveToServer : MonoBehaviour { #if UNITY_WEBGL && !UNITY_EDITOR public void OnPointerDown(PointerEventData eventData) { } public static void SaveWEB() { SaveToserver(); } #else public static void SaveWEB() { SaveToserver(); } #endif public static void SaveToserver() { string list = ""; List List = new(); print("_G.PON ==="+_G.PON ); if (_G.PON == "SOFTCOLOR") { List = _G.UIT_LibrarySoftColors; } else if (_G.PON == "CABINETpnl") { List = _G.UIT_LibraryCabinets; } else if (_G.PON == "PANELpnl") { List = _G.UIT_LibraryPanels; } else if (_G.PON == "MOLDINGpnl") { List = _G.UIT_LibraryMoldings; } else if (_G.PON == "CABTEXTUREpnl") { List = _G.UIT_LibraryCabTextures; } else if (_G.PON == "CABTEXTUREpnl") { List = _G.UIT_LibraryCabTextures; } else if (_G.PON == "CREATORpnl_Panel") { List = _G.UIT_LibraryPanels; } else if (_G.PON == "CREATORpnl_CabTexture") { List = _G.UIT_LibraryCabTextures; } else if (_G.PON == "CREATORpnl_Door") { List = _G.UIT_LibraryDoors; } else if (_G.PON == "CREATORpnl_Molding") { List = _G.UIT_LibraryMoldings; } else if (_G.PON == "STORESpnl") { List = _G.UIT_LibraryStores; } else if (_G.PON == "PreferenceSetting") { foreach(KeyValuePair entry in _P.List){ print("To server=======" + entry.Key + "," + _P.List[entry.Key]); List.Add( entry.Key+","+_P.List[entry.Key]); } } else if (_G.PON == "LEXICONpnl") { List = _G.UIT_LibraryLexique; } else if (_G.PON =="ListPriceInputpnl") { List = _G.UIT_LibraryPrices; } else if (_G.PON =="GLOBALSTART") { List = _G.UIT_LibraryGlobalStart; } else if (List == null) return; for (int i = 0; i < List.Count; i++) { if(!string.IsNullOrEmpty(List[i])){list += List[i] + ("\n");} } print("SaveToserver ===1"); //print("list==="+list); SaveToserver(list); } public static void SaveToserver(string list) { print("SaveToserver ===2"); WWWForm form = new(); string name=""; if( _G.PON =="CABINETpnl")name="CABINET"; else if( _G.PON =="PreferenceSetting")name="PREFERENCES"; else if (_G.PON =="CREATORpnl_Panel") { name="PANEL"; } else if (_G.PON =="CREATORpnl_Molding") { name="MOLDING"; } else if (_G.PON =="CREATORpnl_CabTexture") { name="CABTEXTURE"; } else if (_G.PON =="CREATORpnl_Door") { name="DOOR"; } else if (_G.PON =="STORESpnl") { name="STORE"; } else if (_G.PON =="LEXICONpnl") { name="LEXIQUE"; } else if (_G.PON =="SOFTCOLOR") { name="SOFTCOLOR"; } else if (_G.PON =="ListPriceInputpnl") { name="PRICE"; } else if (_G.PON =="CREATORpnl_Kick") { name="MOLDING"; } else if (_G.PON =="GLOBALSTART") { name="GLOBALSTART"; } form.AddField("filename", name+"List"); form.AddField("csvdata", list); form.AddField("path", _G.PATH + "/library/"); StaticCoroutine.Start(SaveToServerCoroutine(form)); } public static IEnumerator SaveToServerCoroutine(WWWForm form) { print("SaveToserver ===3"); string url = _P.PathServer + "members/savecsv.php"; UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error + " " + url); } else { _M.PH(18, 0, "ffffff", 1, 1); yield return new WaitForSeconds(1); Get.o2("HIDER", "MESSAGE").SetActive(false); GameObject Panel =Get.o2("Canvas","Panel_main"); bool MainActive = Panel.activeInHierarchy; DOIT.CloseALLPNL(); if(MainActive)Panel.SetActive(true); } print("SaveToserver ===4====="+form); } public static IEnumerator sendTextToFile(string list) { WWWForm form = new WWWForm(); form.AddField("filename", _G.PON + "List"); form.AddField("csvdata", list); string path = _G.PATH + "/library/"; form.AddField("path", path); string url = _P.PathServer + "members/savecsv.php"; UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error + " " + url); } else { _M.PH(18, 0, "ffffff", 1, 1); yield return new WaitForSeconds(1); Get.o2("HIDER", "MESSAGE").SetActive(false); DOIT.CloseALLPNL(); } yield break; } }