using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using System.Xml; using TMPro; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.AddressableAssets; using Unity.VisualScripting; public class LoadXML : MonoBehaviour { static XmlDocument xmlDoc = null; static List OBJS; static List CABS; static bool _aiProcessLaunched; // mode AI : ProcessAi ne démarre qu'une fois par chargement //static float Wait = 1; //------------------------------------------------CONSTRUCTION ROOM-------------------------------------- public static IEnumerator SetGlobal(XmlDocument xmldoc) { print("SetGloba===2="+" time==="+Time.time); WaitCircle.Setting(true, TRANS.This("M_Download") ); yield return null; xmlDoc = xmldoc; //_G.FileName = StringXML("//Room/FILENAME"); //print("File name on load===" + _G.FileName); string oldClient = StringXML("//Room/CLIENT"); string oldVersionNumber = StringXML("//Room/VERSION"); if (!SaveCompatibility.RefID_CheckedOnce && StringXML("//Room/REPLACE_ROOMID") != "none") { SaveCompatibility.SetVersionCompatibility_RefID(BoolXML("//Room/REPLACE_ROOMID")); } SuspendedCab.IsCompatible_VersionAddedLine14 = IsVersionCompatible(oldVersionNumber, SuspendedCab.VersionAddedLine14); //Global _G.OW.Clear(); _G.OP.Clear(); _G.WallsWidth.Clear(); _G.WallsPointCenter.Clear(); _G.WallsPointStart.Clear(); _G.WallsAngle.Clear(); _G.WallsDirection.Clear(); _G.WALL.Clear(); //_G.Ws.Clear(); _G.WallsMaterial.Clear(); _G.WallsColor.Clear(); _G.WallsTexture.Clear(); _G.WallsAngle.Clear(); //Global _G.HEIGHT = NumXML("//Room/GLOBAL/HEIGHT"); _G.WIDE = NumXML("//Room/GLOBAL/WIDE"); _G.DEPTH = NumXML("//Room/GLOBAL/DEPTH"); _G.ROOM = StringXML("//Room/GLOBAL/ROOM"); _G.FLCs = StringXML("//Room/FLOOR/code"); _G.WMKs = StringXML("//Room/GLOBAL/WMKs"); _G.WMOs = StringXML("//Room/GLOBAL/WMOs"); _G.SUN = StringXML("//Room/GLOBAL/SUN"); _G.UIT_YourLibrary = StringXML("//Room/GLOBAL/YourLibrary"); _G.StoreZone = StringXML("//Room/GLOBAL/storezone"); if (_G.StoreZone == "none") { _G.StoreZone = ""; } if (_P.ListSwitch["STORE_SELECTION"]) { if (_G.PATH == "kent" && _G.StoreZone == "_1") _G.StoreZone = "_1010"; } GameObject.Find("Canvas").transform.Find("Panel_main").gameObject.SetActive(false); GameObject.Find("Canvas").transform.Find("Panel_SCENE").gameObject.SetActive(true); _G.PNL = "WORLD3D"; _G.LightSetting = GetLightSetting(); _G.ClientInfo = GetClientInfo(); _G.EMAIL = _G.ClientInfo["Email"]; print("email =======+email load===="+_G.EMAIL ); _G.OBJnum = 0; _G.WMK = _G.WMKs.Split(","[0]); _G.WMO = _G.WMOs.Split(","[0]); if (_G.ROOM == "RDRAW") { _G.NW = IntXML("//Room/GLOBAL/NW"); } _G.OW.AddRange(new Vector2[_G.NW]); _G.OP.AddRange(new Vector2[_G.NW]); _G.WallsWidth.AddRange(new float[_G.NW]); _G.WallsPointCenter.AddRange(new Vector2[_G.NW]); _G.WallsPointStart.AddRange(new Vector2[_G.NW]); _G.WallsAngle.AddRange(new float[_G.NW]); _G.WallsDirection.AddRange(new int[_G.NW]); _G.WALL.AddRange(new GameObject[_G.NW]); //_G.Ws.AddRange(new GameObject[_G.NW]); _G.WallsMaterial.AddRange(new Material[_G.NW]); for (int i = 0; i < _G.WallsMaterial.Count; i++) { _G.WallsMaterial[i] = _G.GYPSE; } _G.WallsColor.AddRange(new string[_G.NW]); _G.WallsTexture.AddRange(new string[_G.NW]); _G.WallsAngle.AddRange(new float[_G.NW]); _G.OBJnum = 0; _G.WMK = _G.WMKs.Split(","[0]); _G.WMO = _G.WMOs.Split(","[0]); //Set Globals _G.UIT_LibraryGlobalStart = GetGlobalSetting(); _G.UIT_LibraryCabTextures = GetCabTextureList(); //AI PREFERENCES if(StringXML("//Room/GLOBAL/Countertop") != "none"){ UIT.GlobalSet(Header.Counter, StringXML("//Room/GLOBAL/Countertop") , 1); } _G.Island=StringXML("//Room/GLOBAL/Island") ; string wallSelect = StringXML("//Room/WallCabs"); print("Wall selected from RD" + wallSelect); if (wallSelect == "none" || string.IsNullOrEmpty(wallSelect)) { _G.WallSelected = new() { "m3_2", "m4" }; } else { // Format : murs séparés par ';', sections d'un mur par ',' après '_' (ex. "m3_1,2;m4"). _G.WallSelected = new(); foreach (string w in wallSelect.Split(';', ' ')) { string entry = w.Trim(); if (entry.Length > 0) _G.WallSelected.Add(entry); } } //Your Library Created _Add.YOUR_DOORS = GetYourLibrary("//Room/GLOBAL/YOUR_DOORS"); _Add.YOUR_PANELS = GetYourLibrary("//Room/GLOBAL/YOUR_PANELS"); _Add.YOUR_TEXTURES = GetYourLibrary("//Room/GLOBAL/YOUR_TEXTURES"); // Options du design (ex. "Glass Door"), séparées par ';'. Conditionne certaines étapes AI. _G.OPTIONS = new(); string optionsStr = StringXML("//Room/GLOBAL/Options"); if (optionsStr != "none" && !string.IsNullOrEmpty(optionsStr)) { foreach (string opt in optionsStr.Split(';')) { string o = opt.Trim(); if (o.Length > 0) _G.OPTIONS.Add(o); } } // //_G.PREFERNCES = new(); // string preferencesStr = StringXML("//Room/GLOBAL/Preferences"); // if (preferencesStr != "none" && !string.IsNullOrEmpty(preferencesStr )) // { // foreach (string opt in preferencesStr.Split(';')) // { // string o = opt.Trim(); // if (o.Length > 0) _G.PREFERNCES.Add(o); // } // } //Set Global LoadWallData(); string wallPointPositions = StringXML("//Room/WallPointPositions"); string wallPointPairings = StringXML("//Room/WallPointPairings"); if (wallPointPositions == "none") { wallPointPositions = "-8,192;-8,8;-192,8;-192,192;"; wallPointPairings = "0,1;1,2;2,3;3,0;"; } if (wallPointPositions != "none" && wallPointPairings != "none") { RoomCreation.LoadRoomPlanFromSave(wallPointPositions, wallPointPairings); } else if (wallPointPositions != "none") { RoomCreation.LoadRoomPlanFromSave(wallPointPositions, ""); } else { //print("Load pass here==="+_G.NWExterior); //_G.NWExterior=_G.NW; RoomCreation.LoadRoomPlanFromSave("", ""); } //if (_G.BKN == 0) _G.BKN = 1; //if (_G.FLCs.Split(',').Length < 9) { _G.FLCs += ",ffffff,1"; } if(_G.FLCs.Contains("WOOD.1,")){_G.FLCs="WOOD.1,#E2DABD,#A89186,#D4D4D4,1,0,0.1,0.2,0.3";} RoomCreation.CreateRoomTo3D(); _G.OBJs[299] = new string[100]; _G.OBJs[299][0] = "null"; _G.OBJs[299][1] = "null"; yield return ColorWalls(); Floor(); Camera(); if (_G.FlieCategory == "ai") { _G.AI_PREFERENCES = GetAiPreferences(); //Set Knobs string ColorHex=AI.ColorHEX(_G.AI_PREFERENCES["KnobsColor"]);// UIT.GlobalSet(Header.KnobV, "K_1?V?"+ColorHex+"_Glossy?1?1?1", 1);//ID,Color,Sens,Wide,Height,Depth UIT.GlobalSet(Header.KnobH, "K_1?H?"+ColorHex+"_Glossy?1?1?1", 1);//ID,Color,Sens,Wide,Height,Depth print("(_G.AI_PREFERENCES[KnobsColo"+_G.AI_PREFERENCES["KnobsColor"]); //Color Appliances //Color Sink //Color Faucet } yield return Molding(); yield return Cabinets(); CheckClient(oldClient); CheckVersion(oldVersionNumber); if(CABS.Count + OBJS.Count==0){CoroutineController.Start(StopLoading());} } //------------------------------------------------VERSION CLIENT------------------------------------- private static void LoadWallData() { if (_G.ROOM == "RDRAW") { _G.NW = IntXML("//Room/GLOBAL/NW"); } //Debug.Log($"wall number on load : {_G.NW}"); //print("_G.NW=="+_G.NW); _G.OW.AddRange(new Vector2[_G.NW]); _G.OP.AddRange(new Vector2[_G.NW]); _G.WallsWidth.AddRange(new float[_G.NW]); _G. WallsPointCenter.AddRange(new Vector2[_G.NW]); _G.WallsPointStart.AddRange(new Vector2[_G.NW]); _G.WallsAngle.AddRange(new float[_G.NW]); _G. WallsDirection.AddRange(new int[_G.NW]); _G.WALL.AddRange(new GameObject[_G.NW]); //_G.Ws.AddRange(new GameObject[_G.NW]); _G. WallsMaterial.AddRange(new Material[_G.NW]); for (int i = 0; i < _G. WallsMaterial.Count; i++) { _G. WallsMaterial[i] = _G.GYPSE; } _G. WallsColor.AddRange(new string[_G.NW]); _G. WallsTexture.AddRange(new string[_G.NW]); _G.WallsAngle.AddRange(new float[_G.NW]); for (int i = 1; i < _G.NW + 1; i++) { _G.WallsWidth[i - 1] = NumXML("//Room/W" + i.ToString() + "/w"); float xCP = NumXML("//Room/W" + i.ToString() + "/px"); float yCP = NumXML("//Room/W" + i.ToString() + "/pz"); _G. WallsPointCenter[i - 1] = new Vector2(xCP, yCP); _G.WallsAngle[i - 1] = NumXML("//Room/W" + i.ToString() + "/wa"); //_G. WallsTexture[i-1] = StringXML("//Room/W"+i.ToString()+"/tex"); float dx = (_G.WallsWidth[i - 1] / 2) * Mathf.Cos(_G.WallsAngle[i - 1] * Mathf.PI / 180); float dy = (_G.WallsWidth[i - 1] / 2) * Mathf.Sin(_G.WallsAngle[i - 1] * Mathf.PI / 180); _G.WallsPointStart[i - 1] = new Vector2(_G. WallsPointCenter[i - 1].x - dx, _G. WallsPointCenter[i - 1].y + dy); //_G.WallsWidth.Add(NumXML("//Room/W" + i.ToString() + "/w")); //float xCP = NumXML("//Room/W" + i.ToString() + "/px"); //float yCP = NumXML("//Room/W" + i.ToString() + "/pz"); //_G. WallsPointCenter.Add(new Vector2(xCP, yCP)); //_G.WallsAngle.Add(NumXML("//Room/W" + i.ToString() + "/wa")); ////_G. WallsTexture[i-1] = StringXML("//Room/W"+i.ToString()+"/tex"); //float dx = (_G.WallsWidth[i - 1] / 2) * Mathf.Cos(_G.WallsAngle[i - 1] * Mathf.PI / 180); //float dy = (_G.WallsWidth[i - 1] / 2) * Mathf.Sin(_G.WallsAngle[i - 1] * Mathf.PI / 180); //_G.WallsPointStart.Add(new Vector2(_G. WallsPointCenter[i - 1].x - dx, _G. WallsPointCenter[i - 1].y + dy)); } } /// Nom (ou chemin/URL) du fichier ouvert. Si fourni, il pose /// _G.FileName et _G.FlieCategory. Laisser null quand le nom n'est pas connu (ex. WebGL). public static void SetGLOBAL(XmlDocument xmldoc, string fileName = null) { if (xmldoc == null || xmldoc.SelectSingleNode("//Room") == null) { Debug.LogWarning("SetGLOBAL: fichier invalide ou introuvable — chargement annulé."); _M.PH(36, 230, "ffffff", 1, 1); WaitCircle.Setting(false, TRANS.This("M_Download")); return; } //print("SetGloba===1=" + " time===" + Time.time); _aiProcessLaunched = false; // nouveau chargement : le process AI pourra repartir ApplyFileName(fileName); StaticCoroutine.Start(SetGlobal(xmldoc)); //print("SetGloba===3="+" time==="+Time.time); } /// /// _G.FileName = nom du fichier sans extension, et _G.FlieCategory = "ai" si le nom /// contient "ai_". Commun au web, à l'éditeur et au standalone PC. /// static void ApplyFileName(string fileName) { // Nom inconnu (ex. WebGL, qui ne reçoit que le contenu) : on garde l'existant. if (string.IsNullOrEmpty(fileName)) return; string name = fileName; int q = name.IndexOf('?'); // enlève la query string d'une URL if (q >= 0) name = name.Substring(0, q); name = Path.GetFileNameWithoutExtension(name); // enlève le chemin et l'extension (.udt) if (string.IsNullOrEmpty(name)) return; _G.FileName = name; _G.FlieCategory = name.IndexOf("ai_", StringComparison.OrdinalIgnoreCase) >= 0 ? "ai" : "Design"; Debug.Log($"[LoadXML] FileName='{_G.FileName}' FlieCategory='{_G.FlieCategory}'"); } static private void CheckClient(string client) { if (string.IsNullOrEmpty(client) || client == "none") { Debug.Log("No client found when loading UDT"); return; } if (client != _G.PATH) { Debug.Log($"Client is not matching between saves. Old save : {client}, Current : {_G.PATH}"); return; } } static private void CheckVersion(string version) { if (string.IsNullOrEmpty(version) || version == "none") { Debug.Log("No version found when loading UDT"); return; } if (!SaveCompatibility.RefID_CheckedOnce && !string.IsNullOrEmpty(_G.ref_id)) { SaveCompatibility.SetVersionCompatibility_RefID(version); } if (version != _G.VER) { Debug.Log($"Version is not matching between saves. Old save : {version}, Current : {_G.VER}"); return; } } static private bool IsVersionCompatible(string savedVersion, string compatibleVersion) { bool isCompatible = false; List savedVersionNumbers = GetVersionNumbers(savedVersion); List compatibleVersionNumbers = GetVersionNumbers(compatibleVersion); for (int i = 0; i < savedVersionNumbers.Count; i++) { bool isLongerVersionLength = i >= compatibleVersionNumbers.Count; if (isLongerVersionLength) { bool isVersionHigherIteration = i > 0 && savedVersionNumbers[i - 1] == compatibleVersionNumbers[i - 1]; isCompatible = isVersionHigherIteration || i == 0; break; } bool isVersionHigher = savedVersionNumbers[i] > compatibleVersionNumbers[i]; if (isVersionHigher) { isCompatible = true; break; } bool isVersionLower = savedVersionNumbers[i] < compatibleVersionNumbers[i]; if (isVersionLower) { isCompatible = false; break; } bool isSameVersion = i == savedVersionNumbers.Count - 1 && savedVersionNumbers[i] == compatibleVersionNumbers[i]; if (isSameVersion) { isCompatible = true; break; } } return isCompatible; } static private List GetVersionNumbers(string version) { List outList = new(); string[] stringVersionNumbers = version.Split('.'); foreach (string versionNumber in stringVersionNumbers) { if (int.TryParse(versionNumber, out int number)) { outList.Add(number); } } return outList; } private static Dictionary GetLightSetting(){ Dictionary Dic=_G.LightSetting; string code=StringXML("//Room/GLOBAL/LightSetting"); if(code!=null && code!="none"){ Dic.Clear(); string[] Code=code.Split('?'); for(int i=0;i GetLightColor(){ Dictionary Dic=_G.LightColor; string code=StringXML("//Room/GLOBAL/LightColor"); if(code!=null && code!="none"){ Dic.Clear(); string[] Code=code.Split('?'); for(int i=0;i GetClientInfo(){ Dictionary Dic=_G.ClientInfo; string code=StringXML("//Room/GLOBAL/ClientInfo"); //print("code==="+code);//code===System.Collections.Generic.Dictionary`2[System.String,System.String] if(code!="none" && code.IndexOf("System.Collections")==-1){ Dic.Clear(); string[] Code=code.Split('?'); for(int i=0;i GetGlobalSetting(){ List ListGlobal=_G.UIT_LibraryGlobalStart; print("_G.UIT_LibraryGlobalStart====="+_G.UIT_LibraryGlobalStart[0]); for(int i=1; i<_G.UIT_LibraryGlobalStart.Count; i++) { string Global=StringXML("//Room/GLOBAL/Global"+i.ToString()); print(i+" Global====="+Global); // G_1,4?14, // K_1?5?4.5, // MELAMINEWHITE?90, // 6?6, // NONE?1?0, // NONE?1?0, // FA_1?2?6, // NONE?1?90?0, // SPLA.16?#FFFFFF?#B4B1B1?#C8C7C7?1.678608-1.653885?0?1?0.9?0.3?0, // COUN.15?#FFFFFF?#A4A4A4?D4D3D3?0.5660949-0.9863777?55?1?0.9?0.3?0, // K_6?V?#555555_Mat_none?6.57?0.39?1.1, // K_6?V?#555555_Mat_none?6.57?0.39?1.1, // end if(Global!="none" && Global.Split(',')[1]!="none" ){ _G.UIT_LibraryGlobalStart[i]=Global; } } //if old file with no glass //if(_G.UIT_LibraryGlobalStart[1]) return ListGlobal; } private static List GetCabTextureList(){ string ListXml=StringXML("//Room/GLOBAL/CabtextureList"); List ListCabTexture = _G.UIT_LibraryCabTextures; if(ListXml!="none" && !string.IsNullOrEmpty(ListXml)) { ListXml=ListXml.Replace("Unique_Name","UniqueName"); ListCabTexture=new(){}; string[] Liststring = ListXml.Split("_"); foreach(string str in Liststring){ if(!string.IsNullOrEmpty(str)){ ListCabTexture.Add(str); } } } return ListCabTexture; } private static List GetYourLibrary(string Path) { List list = new(); string YourLibrary = StringXML(Path); //print("YourLibrary=====Load===" + YourLibrary); if(YourLibrary!="none" && !string.IsNullOrEmpty(YourLibrary)) { return new List(YourLibrary.Split("__")); } return list; } private static Dictionary GetAiPreferences(){ //Dictionary Dic=_G.AI_PREFERENCES ; string code=StringXML("//Room/GLOBAL/Preferences"); //code==========Inspiraation:?Countertop:?Island:?Budget:?ApliancesColor:888888?SinkFaucetColor:888888?KnobsColor:888888 print("code=========="+code); if(code!=null && code!="none"){ _G.AI_PREFERENCES .Clear(); string[] Code=code.Split('?'); for(int i=0;i 1 || splitSideRecipe[0] == "0") { // set loaded value validatedSideRecipe = sideRecipe; } else if (splitSideRecipe.Length == 1) { // set default validatedSideRecipe = AddRecoverToCabinet.GetDefaultRecoverValue(objectIndex); } string recipeSeparator = isFirstIndex ? "" : "_"; validatedRecoverRecipe += $"{recipeSeparator}{validatedSideRecipe}"; isFirstIndex = false; } _G.OBJs[objectIndex][81] = validatedRecoverRecipe; return; } //------------------------------CABINETS--------------------------------------------------- public static IEnumerator Cabinets() { yield return new WaitForEndOfFrame(); CameraAround.Show(); DASH.HDsetBTNcolor(false); //yield return new WaitForEndOfFrame(); CABS = new List(); XmlNode node; string path; for (int i = 0; i < 100; i++) { path = "//Room/CABINET" + i.ToString() + "/O0"; node = xmlDoc.DocumentElement.SelectSingleNode(path); if (node != null) { _G.Download_qty+=1; CABS.Add(i.ToString()); GetCode("//Room/CABINET", i); //ValidateData(i); } //yield return new WaitForEndOfFrame(); } OBJS = new List(); for (int i = 0; i < 200; i++) { path = "//Room/OBJECT" + i.ToString() + "/O0"; node = xmlDoc.DocumentElement.SelectSingleNode(path); if (node != null) { _G.Download_qty+=1; OBJS.Add(i.ToString()); GetCode("//Room/OBJECT", i); //ValidateData(i); //print("From load object i===="+i); } //yield return new WaitForEndOfFrame(); } foreach (string str in CABS) { yield return CreateCabinet(str); } foreach (string str in OBJS) { StaticCoroutine.Start(CreateObjects(str)); yield return new WaitUntil(() => _G.Load == true); } } private static IEnumerator CreateCabinet(string str) { //yield return new WaitForSeconds(Wait); int i = int.Parse(str); //print("CreateCabinet()===="+str); if (_G.OBJs[i][0] != "null") { //CORRECTION CorrectionLoading(i); if (_G.OBJs[i][5] == "BA" && _G.OBJs[i][68] != "NONE") { CoroutineController.Start(LoadObjects(i)); } if (_G.OBJs[i][5] == "BA" && _G.OBJs[i][68] == "NONE") ConstructBASE.AddCab(i); if (_G.OBJs[i][5] == "WA") ConstructWALL.AddCab(i); if (_G.OBJs[i][5] == "TA") ConstructTALL.AddCab(i); if (_G.OBJs[i][5] == "CB") ConstructCORNERBASE.AddCab(i); if (_G.OBJs[i][5] == "CW") ConstructCORNERWALL.AddCab(i); if (_G.OBJs[i][5] == "PNL") ConstructPanel.AddPanel(i); //_G.OBJs[i][89]=_G.OBJs[i][0]; if (_G.OBJnum <= i) _G.OBJnum = i + 1; } _G.Download_qty-=1; CoroutineController.Start(StopLoading()); yield return null; } private static void CorrectionLoading(int i) { if (_G.OBJs[i][14] == "none") correction.C14(i); if (_G.OBJs[i][48] == "none") _G.OBJs[i][49]="COLLISION"; if (_G.OBJs[i][49] == "none") _G.OBJs[i][49]="COLLISION"; if (_G.OBJs[i][28].IndexOf("m") != -1) correction.C28(i); if (_G.OBJs[i][28] == "none") correction.C28(i); if (_G.OBJs[i][85] == "none") correction.C85(i); if (_G.OBJs[i][86] == "none") correction.C86(i); if (_G.OBJs[i][85].Split('?').Length == 1) correction.C85(i); if (_G.OBJs[i][86].Split('?').Length == 1) correction.C86(i); if (_G.OBJs[i][85].IndexOf("NONE") != -1) correction.C85(i); if (_G.OBJs[i][86].IndexOf("NONE") != -1) correction.C86(i); if (_G.OBJs[i][29] == "none") correction.C29(i); if (_G.OBJs[i][34] == "none") correction.C34(i); if (_G.OBJs[i][82] == "none") _G.OBJs[i][82] = UIT.Global(Header.Ext,_G.G);//GlobalSelectionManager.GetValue(GlobalOption.EXTPNL_2); if (_G.OBJs[i][83] == "none") correction.C83(i); correction.C41(i); if (_G.OBJs[i][60] == "GLOBAL") _G.OBJs[i][60] = "GLOBAL" + _G.G.ToString(); if (_G.OBJs[i][11] == "none" || _G.OBJs[i][2] == "Panel") correction.C11(i); _G.OBJs[i][89] = _G.OBJs[i][0]; if(_G.OBJs[i][40].Split("?").Length<4)_G.OBJs[i][40]="Off_150_F1E6B7?Off_10_F1E6B7?Off_10_F1E6B7?Off_10_F1E6B7"; //ListSetUp.namechange(i); } //------------------------------OBJECTS--------------------------------------------------- private static IEnumerator CreateObjects(string str) { //print("From load object str===="+str); int i = int.Parse(str); //print("CreateObjectst()===="+str); string[] c = _G.OBJs[i]; if (c[0] != "null") { //print("c[0]===="+c[0]); // Sans categorie (O2 absent du fichier) aucun Construct* n'est appele plus bas : // on la retrouve a partir du modele (O1) avant tout le reste. if (c[2] == "none" || string.IsNullOrEmpty(c[2])) correction.C2(i); if (_G.OBJs[i][14] == "none") correction.C14(i); c[89] = c[0]; //Correction if (c[60] == "GLOBAL") c[60] = "GLOBAL" + _G.G.ToString(); if (c[61].IndexOf("GPNL") != -1) correction.C61pnl(i); if (c[26] == "none") correction.C26(i); if (c[28].Length == 6 && c[4] != "wine") correction.C28(i); if (c[28].IndexOf("m") != -1) correction.C28(i); if (c[28] == "none") correction.C28(i); if (c[29] == "none") correction.C29(i); if (c[2] == "Bloc") correction.C41(i); if (c[11] == "none" || c[2] == "Panel") correction.C11(i); //print("c[0]===="+c[0]); if (c[2] == "Opening") { ConstructOpen.AddOpen(i); } if (c[2] == "Patio") { ConstructPatio.AddPatio(i); } if (c[2] == "Door") { ConstructDoor.AddDoor(i); } if (c[2] == "Bloc") { ConstructBloc.AddBloc(i); } if (c[2] == "Picture") { ConstructPicture.AddPicture(i); } if (c[2] == "Window") { ConstructWindow.AddWindow(i); } if (c[4] == "hood") ConstructHood.AddHood(i); if (c[4] == "panel") ConstructPanel.AddPanel(i); if (c[4] == "Slider") ConstructSlider.AddSlider(i); if (c[2] == "Counter") { ConstructCounter.AddCounter(i); } if (c[2] == "Mirrors") { ConstructMirror.AddMirror(i); } if (c[2] == "Splash") { ConstructSplash.AddSplash(i); } // dosseret AI sauvegardé // if (c[2] == "Deco") { ConstructDECO.AddObject(i); } if (c[4] == "frid") { CoroutineController.Start(LoadObjects(i)); } if (c[4] == "micr") { CoroutineController.Start(LoadObjects(i)); } if (c[4] == "wadr") { CoroutineController.Start(LoadObjects(i)); } if (c[4] == "dish") { CoroutineController.Start(LoadObjects(i)); } if (c[4] == "wine") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Small") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Stool") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Chair") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Table") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Ornament") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Toilet") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Bath") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Shower") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "BathSink") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Vase") { CoroutineController.Start(LoadObjects(i)); } if (c[2] == "Lamp") { CoroutineController.Start(LoadObjects(i)); } if (c[1].Length >= 4) { if (c[1][..4] == "PLAT") { CoroutineController.Start(LoadObjects(i)); } if (c[1][..4] == "TOPS") { CoroutineController.Start(LoadObjects(i)); } if (c[1][..4] == "BUIL") { CoroutineController.Start(LoadObjects(i)); } if (c[1][..4] == "STOV") { CoroutineController.Start(LoadObjects(i)); } } //c[89] = c[0]; } if (_G.OBJnum <= i) {_G.OBJnum = i + 1;} _G.Download_qty-=1; CoroutineController.Start(StopLoading()); yield return null; } private static IEnumerator LoadObjects(int i) { if (_G.OBJs[i][2] == "Stool") { ConstructStool.AddStool(i); } else if (_G.OBJs[i][2] == "Chair") { ConstructChair.AddChair(i); } else if (_G.OBJs[i][2] == "Table") { ConstructTable.AddTable(i); } else if (_G.OBJs[i][2] == "Ornament") { ConstructOrnament.AddOrnament(i); } else if (_G.OBJs[i][2] == "Vase") { ConstructVase.AddVase(i); } else if (_G.OBJs[i][2] == "Lamp") { ConstructLamp.AddLamp(i); } else if (_G.OBJs[i][2] == "Small") ConstructSmallelectro.AddSmallElectro(i); else if (_G.OBJs[i][2] == "Toilet") ConstructToilet.AddToilet(i); else if (_G.OBJs[i][2] == "Bath") ConstructBath.AddBath(i); else if (_G.OBJs[i][2] == "Shower") ConstructShower.AddShower(i); else if (_G.OBJs[i][2] == "BathSink") ConstructBathSink.AddBathSink(i); else if (_G.OBJs[i][5] == "BA") ConstructBASE.AddCab(i); else if (_G.OBJs[i][4] == "frid") ConstructFRIDGE.AddFridge(i); else if (_G.OBJs[i][4] == "micr") ConstructMicrowave.AddMicrowave(i); else if (_G.OBJs[i][4] == "wadr") ConstructWD.AddWD(i); else if (_G.OBJs[i][4] == "dish") ConstructDishwasher.AddDishwasher(i); else if (_G.OBJs[i][4] == "wine") ConstructWiner.AddWiner(i); else if (_G.OBJs[i][1].Length >= 4) { string Cat=_G.OBJs[i][1][..4]; if (Cat== "PLAT") ConstructPlatestove.AddStovePlates(i); else if (Cat == "BUIL") ConstructBuildin.AddBuilding(i); else if (Cat== "STOV") ConstructStove.AddStove(i); else if (Cat == "TOPS") ConstructPlatestove.AddStovePlates(i); } yield return new WaitForEndOfFrame(); //yield return null; } private static IEnumerator StopLoading() { //print("------------------------stop loading--------------------------------------1-----"+_G.Download_qty+" time==="+Time.time); if (_G.Download_qty == 0 && _G.Download_qty < 4000) { WaitCircle.Setting(true, TRANS.This("M_Download")); yield return null; if (GameObject.Find("TEMPLATEpnl")) { Set.alpha(GameObject.Find("TEMPLATEpnl"), false); } SceneModeManager.Instance.SetSceneMode(SceneModes.Navigate); GameObject.Find("MainCamera").GetComponent().Hide(); Get.o2("Canvas/Panel_SCENE", "DASH").SetActive(true); GameObject.Find("FN").GetComponent().text = _G.FileName; if (_G.NT == true) { _M.PH(19, 0, "ffffff", 1, 1); _G.NT = false; } Shopify.ShowEcommeceIcon(); DASH.REFRESH(); WaitCircle.Setting(true, TRANS.This("M_Download")); yield return null; //yield return new WaitForSeconds(3); Shopify.ShowEcommeceIcon(); SelectLight.Set_All_Lights_to_Scene(); _G.Download_qty = 5000; DOIT.CloseALLPNL(); //print("StopLoading===" + _G.Download_qty + " time===" + Time.time); //WaitCircle.Setting(false, ""); //yield return null; _MOL.SetMolding(); PRICE.Calprice(); } if (_G.Download_qty < 0) { print("_G.Download_qty====" + _G.Download_qty + " time===" + Time.time); } if (_Add.YOUR_DOORS.Count == 0) _Add.Door(UIT.Global(Header.Door, _G.G)); if (_Add.YOUR_PANELS.Count == 0) _Add.Panel(UIT.Global(Header.Ext, _G.G)); //SelectLight.SetEnvironent(); if(Get.o2("Panel_SCENE", "DASH")!= null && Get.o2("Panel_SCENE", "DASH").activeInHierarchy) {Get.o2("Panel_SCENE/DASH", "btnAI").SetActive(Get.PreferenceBool("AI")); } if (_G.FlieCategory == "ai") { DASH.HDsetBTNcolor(true); Get.o2("Canvas/Panel_SCENE","MAIN BTN").SetActive(false); Get.o2("Canvas/Panel_SCENE","DASH").SetActive(false); _G.CameraCliping=1; AI ai = FindAnyObjectByType(); if (ai != null) { ai.StartPnl(); // APRÈS StartPnl() : celui-ci initialise l'AI (_AI.On, FloorLine, SetAILibrairy, // WallSelected) mais fait aussi PNL.SetActive(true) + Set.alpha(...,true) — et son // champ PNL EST "Ai-Controls". Le masquer avant serait donc annulé. // Set.alpha plutôt que SetActive : l'objet reste actif, donc les coroutines // lancées sur ses enfants pendant ProcessAi() continuent de fonctionner. Set.alpha(Get.o2("Canvas/Panel_SCENE/PNL","Ai-Controls"), false); // Mode AI : lancer le process automatiquement, une seule fois, une fois la pièce // construite (_G.Download_qty passe à 5000 à la fin du bloc de chargement ci-dessus). if (!_aiProcessLaunched && _G.Download_qty >= 5000) { _aiProcessLaunched = true; yield return new WaitForSeconds(1f); // laisser la scène se stabiliser Debug.Log("[LoadXML] Mode AI — lancement automatique de ProcessAi()"); ai.ProcessAi(); } } } } //---------------------------Color Walls------------------------------------------ public static IEnumerator ColorWalls() { int i = 0; for (i = 1; i < _G.NW + 1; i++) { string ns = i.ToString(); if (GameObject.Find("w" + ns)) { string codetexture = StringXML("//Room/W" + ns + "/texturecode"); codetexture=codetexture.Replace("(Clone)", ""); codetexture=codetexture.Replace("_", "-"); if (codetexture.Contains("GYPS.1")) { codetexture = "GYPS.1,#ffffff,#A6A6A6,#ffffff,0.25-0.25,0,1,0,0,0"; } if (codetexture.IndexOf("GYPS.1") == -1) { //codetexture = Set.NewValueCode(codetexture, "null", 0, ","); //codetexture = Set.NewValueCode(codetexture, "0", 7, ",");//Smoothness //codetexture = Set.NewValueCode(codetexture, "0.2", 8, ",");//Glossness } if (string.IsNullOrEmpty(codetexture)) { codetexture = "null,#ffffff,#A6A6A6,#ffffff,0.25-0.25,0,1,0,0,0"; } yield return PaintaWall(GameObject.Find("w" + ns), codetexture); } } Transform ceil = SceneModeManager.Ceil; if (ceil) { string ceilcode = StringXML("//Room/CEIL/texturecode"); foreach (Transform Section in ceil.transform) { yield return PaintCeilling(Section.gameObject, ceilcode); } } for (i = 0; i < _G.NW; i++) { if (GameObject.Find("w" + (i + 1).ToString())) { _G. WallsMaterial[i] = GameObject.Find("w" + (i + 1).ToString()).transform.GetChild(0).GetComponent().material; yield return null; } } if (ceil != null && ceil.childCount > 0) { if (ceil.GetChild(0).TryGetComponent(out var ceilRenderer)) _G.ceilm = ceilRenderer.material; } } public static IEnumerator PaintaWall(GameObject O, string codetexture) { if (codetexture == "none") codetexture = "none,#FFF0D8FF,#827A6E,#5B564D,1-1,0,1,0,0,0.3"; Material MAT= UIT_MATERIAL.GetMaterial(codetexture); O.transform.GetChild(0).GetComponent().material=MAT; if (codetexture.Split(',')[0] == "GYPS.1") {MAT.SetFloat("_Relief", 0);} codetexture=codetexture.Replace(",","?"); string TextureName=codetexture.Split("?")[0]; print("TextureName===="+TextureName); if(TextureName!="null" && TextureName!="GYPS.1" && TextureName!="none" ) { Addressables.LoadAssetAsync(TextureName).Completed += handle => { if (handle.Status == AsyncOperationStatus.Succeeded) { Texture2D tex = Instantiate(handle.Result); MAT.SetTexture("_Texture", tex); O.transform.GetChild(0).GetComponent().material=MAT; } else { Debug.LogError("Failed to load texture: " + O.name); } }; } yield return null; } public static IEnumerator PaintCeilling(GameObject O, string codetexture) { if (codetexture == "none") codetexture = "none,#FFF0D8FF,#827A6E,#5B564D,1-1,0,1,0,0,0.3"; codetexture=codetexture.Replace("(Clone)", ""); codetexture=codetexture.Replace("_", "-"); if (codetexture.Contains("GYPS.1")) { codetexture = "GYPS.1,#ffffff,#A6A6A6,#ffffff,0.25-0.25,0,1,0,0,0"; } Material MAT= UIT_MATERIAL.GetMaterial(codetexture); O.GetComponent().material=MAT; if (codetexture.Split(',')[0] == "GYPS.1") {MAT.SetFloat("_Relief", 0);} codetexture=codetexture.Replace(",","?"); string TextureName=codetexture.Split("?")[0]; print("TextureNameCeiling===="+TextureName); if(TextureName!="null" && TextureName!="GYPS.1" && TextureName!="none" ) { Addressables.LoadAssetAsync(TextureName).Completed += handle => { if (handle.Status == AsyncOperationStatus.Succeeded) { Texture2D tex = Instantiate(handle.Result); MAT.SetTexture("_Texture", tex); O.transform.GetComponent().material=MAT; } else { Debug.LogError("Failed to load texture: " + O.name); } }; } yield return null; } //---------------------------GETTING------------------------------------------ public static float NumXML(string E) { XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); float v = 0; if (node != null) { string NS = node.InnerText.Replace(",", "."); v = DOIT.ConvertStringToNumber(NS); } return v; } public static int IntXML(string E) { XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); int v = 0; if (node != null) { string NS = node.InnerText.Replace(",", "."); v = int.Parse(NS); } return v; } public static string StringXML(string E) { string Estring = "none"; XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); if (node != null) Estring = node.InnerText; return Estring; } public static Color ColorXML(string E) { XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); string Cstring = node.InnerText; Color col = DOIT.CSc(Cstring, 255); return col; } public static bool BoolXML(string E) { XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); string PIN = node.InnerText; bool Pin = true; if (PIN == "false") Pin = false; return Pin; } //---------------------------Texture Walls------------------------------------------ public static Texture2D TextureXML(string E) { XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(E); string Ts = node.InnerText; Texture2D T; if (Ts == "none") T = null; else { string path = "" + Ts; if (Ts == "GypseHorizontal") path = "ROOM/GypseHorizontal"; T = Resources.Load(path) as Texture2D; } return T; } public static Texture2D TextureXMLFloor() { string path = ""; if (_G.FLC[0] == "Plywood12x14") { path = "Plywood12x14"; }; if (_G.FLC[0].Substring(0, 4) == "FLOO") { path = "FINISH/FW/FW" + _G.FLC[0].Substring(4, 3); } if (_G.FLC[0].Substring(0, 4) == "CERA") { path = "FINISH/Ce/Ce" + _G.FLC[0].Substring(4, 3); } Texture2D T; if (_G.FLC[0] == "none") T = null; else T = Resources.Load(path) as Texture2D; return T; } public static Vector2 SetScale() { float scaleX = DOIT.ConvertStringToNumber(_G.FLC[1]); float scaleY = DOIT.ConvertStringToNumber(_G.FLC[2]); Vector2 S = new ((NumXML("//Room/FLOOR/texw") + 500) / scaleX, (NumXML("//Room/FLOOR/texh") + 500) / scaleY); return S; } public static void GetCode(string path, int i) { //print(_G.OBJs[i]); if(_G.OBJs[i]==null){ _G.OBJs[i] = new string[100]; for (int n = 0; n < 100; n++) { _G.OBJs[i][n] = StringXML(path + i.ToString() + "/O" + n.ToString()); //if(n==81){print("Value 81==="+_G.OBJs[i][n]);} } } } //---------------------------Load for web------------------------------------------ //---------------------------Open Close------------------------------------------ public static void CloseLoadPnl() { WaitCircle.Setting(false, ""); } public static void openLoadPnl() { GameObject.Find("HIDER").transform.Find("LOADpnl").gameObject.SetActive(true); GameObject.Find("HIDER").transform.Find("TEMPLATEpnl").gameObject.SetActive(false); SceneModeManager.Instance.SetSceneMode(SceneModes.Panel);//"PNL"; Set.alpha(Get.o2("HIDER","LOADpnl"),true); Set.alpha(Get.o2("HIDER","OpenWebpnl"),false); } }