using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using TMPro; using System.Text; public class Measure : MonoBehaviour { //public Slider DoorColorSlider; // public void startpnl(){ // if (GameObject.Find("ROOM").transform.childCount != 0) { // DOIT.DELETEAllChild("ROOM"); // ResetObjects(); // } // //DOIT.CloseALLPNL(); // GameObject.Find("Canvas").transform.Find("START").gameObject.SetActive(true); // } public void ResetObjects() { DOIT.DELETEAllChild("SCENE"); _G.OBJnum = 0; _G.OBJs = new string[300][]; } public void goFull() { //Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, true, 30); Screen.SetResolution(960, 480, true, 60); } //--------------------------GO PNL---------------------------------------- public void goSTART() { ShowPNL("START"); ResetObjects(); CabinetCollectionSelected();// le bouton de depart reste cache tant que rien n'est choisi } // A brancher sur le OnValueChanged des toggles de START/Cabinet Collection (Universal, IKEA). // Le bouton START n'apparait qu'une fois une collection cochee. public void CabinetCollectionSelected() { GameObject Container = Get.o2("Canvas/START", "Cabinet Collection"); // Conteneur masque (bannieres autres que kitchengo) : il n'y a rien a choisir, // le bouton de depart doit rester accessible. bool Any = Container == null || !Container.activeSelf || Get.TogSelected(Container) != null; GameObject Btn = Get.o2("Canvas/START", "START"); if (Btn != null) Btn.SetActive(Any); } public void goFORM() { ShowPNL("FORM"); } public void goINSPIRATION() { ShowPNL("INSPIRATION"); Selected("INSPIRATION"); } public void goDOORSTYLE() { string fromPNL = _G.PNL;//avant que ShowPNL ne l'ecrase ShowPNL("DOORSTYLE"); Get.o2("Canvas/DOORSTYLE","COLORS DOOR").SetActive(false); Selected("DOORSTYLE"); GameObject SELECTION = Get.o2("DOORSTYLE","SELECTION"); DOIT.AllChildOff(SELECTION); if (_G.PATH == "hampton_bay") { SetDoorByLabel(SELECTION,"1",Color.white); SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"3",Color.white); } if (_G.PATH == "baindepot") { SetDoorByLabel(SELECTION,"2",Color.white); } if (_G.PATH == "bmr") { SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"2B",DOIT.CSc("C6C5C5",255)); SetDoorByLabel(SELECTION,"4",DOIT.CSc("FFE8BD",255)); } if (_G.PATH == "armoiredepot") { SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"2B",DOIT.CSc("C6C5C5",255)); SetDoorByLabel(SELECTION,"4",DOIT.CSc("FFE8BD",255)); } if (_G.PATH == "homehardware") { SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"2B",DOIT.CSc("C6C5C5",255)); SetDoorByLabel(SELECTION,"4",DOIT.CSc("FFE8BD",255)); } if (_G.PATH == "kent") { SetDoorByLabel(SELECTION,"2",DOIT.CSc("919FAB",255)); SetDoorByLabel(SELECTION,"2B",DOIT.CSc("8CA496",255)); SetDoorByLabel(SELECTION,"2C",Color.white); SetDoorByLabel(SELECTION,"4",DOIT.CSc("FFE8BD",255)); SetDoorByLabel(SELECTION,"2D",Color.grey); SetDoorByLabel(SELECTION,"2E",DOIT.CSc("C6C5C5",255)); } if (_G.PATH == "collection_elite") { SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"2B",DOIT.CSc("C6C5C5",255)); } if (_G.PATH is "kwizine" or "kitchensdepot" or "free" or "gabinetstogo" or "kitchengo") { SetDoorByLabel(SELECTION,"1",Color.white); SetDoorByLabel(SELECTION,"2",Color.white); SetDoorByLabel(SELECTION,"3",Color.white); SetDoorByLabel(SELECTION,"1",Color.white); SetDoorByLabel(SELECTION,"4",Color.white); SetDoorByLabel(SELECTION,"5",Color.white); SetDoorByLabel(SELECTION,"6",Color.white); SetDoorByLabel(SELECTION,"7",Color.white); SetDoorByLabel(SELECTION,"8",Color.white); SetDoorByLabel(SELECTION,"9",Color.white); } // Une seule porte proposee pour cette banniere : rien a choisir, on la prend et on passe au comptoir. // On ne saute pas quand on revient de COUNTERTOPSTYLE, sinon son bouton GoBack ne menerait nulle part. if (fromPNL != "COUNTERTOPSTYLE") { GameObject OnlyDoor = OnlyActiveChild(SELECTION); Toggle Tog = OnlyDoor != null ? OnlyDoor.GetComponent() : null; if (Tog != null) { Tog.isOn = true; // Meme enchainement que le bouton FINISH de DOORSTYLE. Preference Pref = FindAnyObjectByType(); if (Pref != null) Pref.DoorModel(); goCOUNTERTOPSTYLE(); } } } // Retourne l'unique enfant actif de O, ou null s'il y en a zero ou plusieurs. private static GameObject OnlyActiveChild(GameObject O) { GameObject Found = null; for (int i = 0; i < O.transform.childCount; i++) { GameObject Child = O.transform.GetChild(i).gameObject; if (!Child.activeSelf) continue; if (Found != null) return null; Found = Child; } return Found; } public void goCOUNTERTOPSTYLE() { ShowPNL("COUNTERTOPSTYLE"); Get.o2("Canvas/COUNTERTOPSTYLE","COLORS COUNTERTOP").SetActive(false); Selected("COUNTERTOPSTYLE"); } public void goDOORCOLOR() { Form.getDoor(); ShowPNL("DOORCOLOR"); Selected("DOORCOLOR"); print("_G.Ds==="+_G.Ds); Get.o1("ImageDoor").GetComponent().sprite=Resources.Load("Images/Kitchen/"+_G.Ds); //DOIT.DELETEAllChild(Get.o4("SELECT","DoorColor","Viewport","ContentColor").name); //Measure.okShow("DOORCOLOR", "FINISH", false); /*string[] dc=_G.Ds.Split('.'); float qty=float.Parse(dc[2]); print("qty==="+qty); List modlist=new List(); for(int i=1; i().sizeDelta = new Vector2 (Wide, Hight); Get.o4("SELECT","DoorColor","Viewport","ContentColor").transform.GetComponent().constraintCount=nrow; Slider DoorColorSlider=Get.o1("DoorColorSlider").GetComponent(); DoorColorSlider.maxValue=maxsv; DoorColorSlider.minValue=minsv; DoorColorSlider.value=0; if(maxsv<25){DoorColorSlider.transform.GetComponent< CanvasGroup>().alpha=0;} else {DoorColorSlider.transform.GetComponent< CanvasGroup>().alpha=1;} for(int i=0; i(path); //print(path); M.transform.Find("Background").GetComponent().sprite = T; M.SetActive(true); M.transform.SetParent(Get.o4("SELECT","DoorColor","Viewport","ContentColor").transform, false); Get.o2("HIDER","BTNSELECTION").SetActive(false); M.transform.GetComponent().isOn=false; }*/ } public void goCOLORROOM(){ ShowPNL("COLORROOM"); Selected("COLORROOM"); } // Panneaux dont les boutons ne sont pas regroupes dans un seul "SELECTION" : Selected() ne s'applique pas. static readonly string[] FINISHCOLORSSEL = { "SELECTION APPLIANCES", "SELECTION SINKFAUCET", "SELECTION KNOBS" }; static readonly string[] ISLANDSEL = { "Selection1", "Selection2" }; // On branche l'ecoute des boutons par code : pas besoin de les cabler un par un dans l'inspecteur. void Listen(string PNL, string[] Containers, UnityAction Handler) { foreach (string S in Containers) { GameObject Container = Get.o2(PNL, S); if (Container == null) continue; foreach (Transform Select in Container.transform) { if (!Select.TryGetComponent(out Toggle Tog)) continue; Tog.onValueChanged.RemoveListener(Handler);// pas de doublon si on revient sur le panneau Tog.onValueChanged.AddListener(Handler); } } } public void go_FINISHCOLORS(){ ShowPNL("FINISHCOLORS"); Listen("FINISHCOLORS", FINISHCOLORSSEL, FINISHCOLORSSelected); FINISHCOLORSSelected(false); } public void FINISHCOLORSSelected(bool _) { // FINISH n'apparait que si une couleur est choisie dans les trois series. bool ok = true; foreach (string S in FINISHCOLORSSEL) { if (Get.TogSelected(Get.o2("FINISHCOLORS", S)) == null) { ok = false; break; } } okShow("FINISHCOLORS", "FINISH", ok); } public void goFLOORROOM(){ ShowPNL("FLOORROOM"); Get.o2("Canvas/FLOORROOM","COLORS FLOOR").SetActive(false); Selected("FLOORROOM"); } public void goISLAND() { ShowPNL("ISLAND"); Listen("ISLAND", ISLANDSEL, ISLANDSelected); ISLANDSelected(false); } public void ISLANDSelected(bool _) { // Selection1 (None/Island/Peninsula/Peninsula L) + Selection2 (STOOL/SINK/COOKTOP) donnent // le nom de l'image : "Island-Sink", "Return-Stool-Cooktop"... "None" n'affiche rien. string Key = Preference.IslandKey(); okShow("ISLAND", "FINISH", Key != null);// il faut au moins un choix dans Selection1 // "None" : les options n'ont plus de sens. On decoche STOOL/SINK/COOKTOP et on masque // le conteneur. Get.o2 le retrouve quand meme une fois inactif : GameObject.Find porte // sur ISLAND, qui reste actif, et Transform.Find voit les enfants desactives. GameObject Options = Get.o2("ISLAND", "Selection2"); if (Key == "None") ClearToggles(Options); if (Options != null) Options.SetActive(Key != "None"); GameObject ShowO = Get.o2("ISLAND", "Show"); if (ShowO == null) return; Sprite Img = null; if (Key != null && Key != "None") { Img = Resources.Load("Images/Icons/Island/" + Key); if (Img == null) print("Image d'ilot introuvable : Images/Icons/Island/" + Key); } if (Img != null) ShowO.GetComponent().sprite = Img; ShowO.SetActive(Img != null); } // Decoche tous les boutons d'un conteneur. SetIsOnWithoutNotify : pas de rappel des listeners, // donc pas de reentrance dans ISLANDSelected. static void ClearToggles(GameObject Container) { if (Container == null) return; foreach (Transform Select in Container.transform) { if (Select.TryGetComponent(out Toggle Tog)) Tog.SetIsOnWithoutNotify(false); } } public void goBUDGET() { ShowPNL("BUDGET"); okShow("BUDGET", "FINISH", true); //Selected("BUDGET"); } public void goSYS() { ShowPNL("SYS"); Selected("SYS"); //DOIT.AllTogchildfalse(GameObject.Find("SELECTION").gameObject); } public void goPLAN2D() { if(_G.PNL=="SYS")system(); ShowPNL("PLAN2D"); Selected("PLAN2D"); DOIT.AllTogchildfalse(GameObject.Find("SELECTION")); roomplan(); } public void goSETDIM(){ if(_Me.roomplan == "" && _G.ROOM != "R7" && _G.ROOM != "R11" && _G.ROOM != "RDRAW"){ ShowPNL("AR"); } else{ ShowPNL("SETDIM"); if (Draw2DNavigation._instance != null) Draw2DNavigation._instance.FitToViewDelayed(); //SetPlan.newRooms(); Get.o2("Canvas","OBSTACLELIST").SetActive(true); DOIT.DELETEAllChild("OBSTACLELIST"); Get.o2("Canvas","OBSTACLELIST").SetActive(false); ResetObjects(); } } public void goCEIL(){ GameObject WallLineContainer=Get.o2("SETDIM/Panel_DRAWPlan_NEW/Plan2D_UI","WallLineContainer"); _G.WallPoints.Clear(); foreach(Transform p in WallLineContainer.transform) { _G.WallPoints.Add(p.gameObject.GetComponent()._pointStart.transform.localPosition); print("V3===="+p.transform.position); } _G.NW=_G.WallPoints.Count; ShowPNL("CEILING"); Get.o3("CEILING","MCe","mCe").GetComponent().text = DOIT.CNs(_G.HEIGHT); print("_G.ROOM==="+_G.ROOM); } public void goOBSTACLES() { print("_G.WIDE===="+_G.WIDE); print("_G.DEPTH===="+_G.DEPTH); print("_G.NW==O=="+_G.NW); //print("wP1===="+_G.wP1); //print("wP2===="+_G.wP2); ShowPNL("OBSTACLES"); SetPlan.Rooms(); Get.o2("Canvas","OBSTACLELIST").SetActive(true); Positioning.AddWallsCollider("OBSTACLES"); SetPlan.FitPlan("OBSTACLES");// ajuste le plan a la zone visible //DOIT.DELETEAllChild("OBSTACLELIST"); // La suppression se fait maintenant depuis la corbeille posee sur l'objet selectionne. GameObject del = Get.o2("OBSTACLES","Delete"); if (del != null) del.SetActive(false); DELETE.Refresh(); } public void goPOSITIONING() { ShowPNL("POSITIONING"); SetPlan.Rooms(); GameObject ol = Get.o2("Canvas","OBSTACLELIST"); ol.SetActive(true); foreach (Transform go in ol.transform) { Transform circleT = go.Find("Circle"); if (circleT != null) circleT.GetComponent().color = Color.red; } Positioning.Start(); SetPlan.FitPlan("POSITIONING");// ajuste le plan a la zone visible } public void goWALLCAB(){ bool gowall=true; Get.o2("Canvas","OBSTACLELIST").SetActive(true); GameObject OL=Get.o1("OBSTACLELIST"); for(int i=0; i().color==Color.red)gowall=false; } if(gowall==true){ ShowPNL("WALLCAB"); okShow("WALLCAB", "FINISH", false); SetPlan.Rooms(); PlaceObjectsOnPlan(OL); SetPlan.FitPlan("WALLCAB");// ajuste le plan a la zone visible } else _M.PH(17, 0, "898787", 1, 1); } public void goOPTIONS() { ShowPNL("OPTIONS"); IslandDoubleShow(); //Selected("OPTIONS"); } // L'option "ilot double" n'a de sens que si un ilot a ete choisi dans ISLAND. static void IslandDoubleShow() { GameObject SELECTION = Get.o2("OPTIONS","SELECTION"); if (SELECTION == null) return; Transform B = SELECTION.transform.Find("IslandDouble"); if (B == null) return; bool show = _G.Island != "none"; if (!show) { Toggle tog = B.GetComponent(); if (tog != null) tog.isOn = false;// sinon l'option resterait cochee dans _G.Options } B.gameObject.SetActive(show); } public static void RebuildWALLCABPlan() { Transform ol = GameObject.Find("Canvas").transform.Find("OBSTACLELIST"); if (ol != null) PlaceObjectsOnPlan(ol.gameObject); } public static void OpenFromWALLCAB(string objName) { string[] parts = objName.Split('_'); if (parts.Length < 2 || !int.TryParse(parts[1], out int n)) return; if (_G.OBJs[n] == null) return; _G.WallSELECTED = _G.OBJs[n][22]; RepositionPNL.StartPNL(objName, null); } static void PlaceObjectsOnPlan(GameObject OL) { Transform plan = Get.o2("WALLCAB", "Plan").transform; var toRemove = new List(); foreach (Transform child in plan) if (child.name.StartsWith("OBJ_")) toRemove.Add(child); foreach (Transform t in toRemove) UnityEngine.Object.Destroy(t.gameObject); for (int i = 0; i < OL.transform.childCount; i++) { string objName = OL.transform.GetChild(i).name; string[] parts = objName.Split('_'); if (parts.Length < 2 || !int.TryParse(parts[1], out int n)) continue; string baseName = parts[0]; if (_G.OBJs[n] == null || _G.OBJs[n][0] == "null") continue; float dx = DOIT.CSn(_G.OBJs[n][15]); float dz = DOIT.CSn(_G.OBJs[n][17]); float w = DOIT.CSn(_G.OBJs[n][6]); float depth = DOIT.CSn(_G.OBJs[n][8]); bool isAppliance = baseName=="DISH"||baseName=="FRIDGE"||baseName=="STOVE"||baseName=="HOOD"||baseName=="WASHER"; bool isWallElement = baseName=="WINDOW"||baseName=="PATIO"||baseName=="DOOR"||baseName=="OPENING"; if (!isAppliance && !isWallElement) continue; float wallAngle = WallAngleAt(dx * 2f, dz * 2f); Vector2 planPos = isWallElement ? ProjectOntoWall(new Vector2(dx * 2f, dz * 2f)) : new Vector2(dx * 2f, dz * 2f); float thickness = isWallElement ? 14f : depth * 2f; GameObject marker = new GameObject("OBJ_" + objName); marker.transform.SetParent(plan, false); RectTransform rt = marker.AddComponent(); rt.anchoredPosition = planPos; rt.pivot = new Vector2(0.5f, 0.5f); rt.localEulerAngles = new Vector3(0, 0, wallAngle); rt.sizeDelta = new Vector2(w * 2f, thickness); Image bg = marker.AddComponent(); bg.color = isAppliance ? new Color32(60, 120, 200, 160) : new Color32(230, 150, 30, 220); Button btn = marker.AddComponent