using System.Collections.Generic; using System.Drawing; using Unity.VisualScripting; //using UnityEditor.Formats.Fbx.Exporter; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UIElements; public class CreateBoxPnl : MonoBehaviour { public static GameObject Side(string Name, float sx, float sy, float sz, float px, float py, float pz, float rx, float ry, float rz, string texcode) { if (texcode.Split('?').Length == 1) {texcode += "?0";} GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.name = Name; obj.GetComponent().enabled = false; obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.position = new Vector3(px, py, pz); obj.transform.rotation = Quaternion.Euler(rx, ry, rz); obj.GetComponent().material = Instantiate(_G.TEXTURE); //obj.GetComponent().material =UIT_MATERIAL.GetCabTexture(texcode.Split("?")[1],"SCENE"); SetMat(obj, texcode); DOIT.SetSizeTex(obj, 2 * 12, 2 * 12, 0, 0, 0, 0, 0, 0); return obj; } public static GameObject SidePanel(string[] C,string Name, float w, float h, float d, float px, float py, float pz) { //F.I.I.I.I.I string[] Finish=new string[] {C[62],C[62],C[62],C[62],C[62],C[62]};//All interior finish string ExteriorFinish=C[82]; //C[78] = "S_I_F?N_O_N?"; string codeFinish=C[78].Split("?")[0]; string codeModel=C[78].Split("?")[1];//N_O_N"; string[] cF=codeFinish.Split("_"); string[] cM=codeModel.Split("_"); string[] RecipeSide=_Recipe[Name].Split('_'); if(codeFinish.IndexOf("S")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="S")Finish[i]=ExteriorFinish; } } if(codeFinish.IndexOf("I")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="I")Finish[i]=ExteriorFinish; } } if(codeFinish.IndexOf("F")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="F")Finish[i]=ExteriorFinish; } } if(codeFinish.IndexOf("T")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="T")Finish[i]=ExteriorFinish; } } if(codeFinish.IndexOf("U")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="U")Finish[i]=ExteriorFinish; } } if(codeFinish.IndexOf("B")!=-1){ for(int i=0; i<6; i++){ if(RecipeSide[i]=="B")Finish[i]=ExteriorFinish; } } string panelModel="S"; for(int i=0; i<6; i++){ if(Name.IndexOf("S"+(i+1).ToString())!=-1){panelModel=cM[i];} } GameObject Panel =new("FACES "+Name); if(panelModel=="S" || panelModel=="N"){ GameObject left = CreateFace("left", d, h, 1, -w / 2, 0, 0, 0, 90, 0, Finish[0]); left.transform.SetParent(Panel.transform); GameObject right = CreateFace("right", d, h, 1, w / 2, 0, 0, 0, -90, 0, Finish[1]); right.transform.SetParent(Panel.transform); GameObject top = CreateFace("top", w, d, 1, 0, h / 2, 0, 90, 0, 0, Finish[2]); top.transform.SetParent(Panel.transform); GameObject front = CreateFace("front", w, h, 1, 0, 0, -d / 2, 0, 0, 0, Finish[3]); front.transform.SetParent(Panel.transform); GameObject under = CreateFace("under", w, d, 1, 0, -h / 2, 0, -90, 0, 0, Finish[4]); under.transform.SetParent(Panel.transform); GameObject back = CreateFace("back", w, h, 1, 0, 0, d / 2, 0, 180, 0, Finish[5]); back.transform.SetParent(Panel.transform); } if(panelModel=="O"){ h+=DOIT.ConvertStringToNumber(C[35]); py-=DOIT.ConvertStringToNumber(C[35])*0.5f; GameObject left = CreateFace("left", d, h, 1, -w / 2, 0, 0, 0, 90, 0, Finish[0]); left.transform.SetParent(Panel.transform); GameObject right = CreateFace("right", d, h, 1, w / 2, 0, 0, 0, -90, 0, Finish[1]); right.transform.SetParent(Panel.transform); GameObject top = CreateFace("top", w, d, 1, 0, h / 2, 0, 90, 0, 0, Finish[2]); top.transform.SetParent(Panel.transform); GameObject front = CreateFace("front", w, h, 1, 0, 0, -d / 2, 0, 0, 0, Finish[3]); front.transform.SetParent(Panel.transform); GameObject under = CreateFace("under", w, d, 1, 0, -h / 2, 0, -90, 0, 0, Finish[4]); under.transform.SetParent(Panel.transform); GameObject back = CreateFace("back", w, h, 1, 0, 0, d / 2, 0, 180, 0, Finish[5]); back.transform.SetParent(Panel.transform); } if(panelModel=="N"|| panelModel=="F") { float K=DOIT.ConvertStringToNumber(C[35]); float kf=DOIT.ConvertStringToNumber(C[33]); float posy=-h*0.5f-K*0.5f; GameObject Bleft = CreateFace("bleft", d-kf, K, 1, -w / 2, posy, +kf*0.5f, 0, 90, 0, Finish[0]); Bleft.transform.SetParent(Panel.transform); GameObject Bright = CreateFace("bright", d-kf, K, 1, w / 2, posy, +kf*0.5f, 0, -90, 0, Finish[1]); Bright.transform.SetParent(Panel.transform); GameObject Btop = CreateFace("btop", w, d, 1, 0, -h / 2, 0, 90, 0, 0, Finish[2]); Btop.transform.SetParent(Panel.transform); GameObject Bfront = CreateFace("bfront", w, K, 1, 0, posy, -d / 2+kf, 0, 0, 0, Finish[3]); Bfront.transform.SetParent(Panel.transform); GameObject Bunder = CreateFace("bunder", w, d-kf, 1, 0, -h / 2-K, +kf*0.5f, -90, 0, 0, Finish[4]); Bunder.transform.SetParent(Panel.transform); GameObject Bback = CreateFace("bback", w, K, 1, 0, posy, d / 2, 0, 180, 0, Finish[5]); Bback.transform.SetParent(Panel.transform); } if(panelModel=="F"){ float df=1.25f; d-=df; GameObject left = CreateFace("left", d, h, 1, -w / 2, 0, df*0.5f, 0, 90, 0, Finish[0]); left.transform.SetParent(Panel.transform); GameObject right = CreateFace("right", d, h, 1, w / 2, 0, df*0.5f, 0, -90, 0, Finish[1]); right.transform.SetParent(Panel.transform); GameObject top = CreateFace("top", w, d, 1, 0, h / 2, df*0.5f, 90, 0, 0, Finish[2]); top.transform.SetParent(Panel.transform); GameObject front = CreateFace("front", w, h, 1, 0, 0, -d / df*0.5f, 0, 0, 0, Finish[3]); front.transform.SetParent(Panel.transform); GameObject under = CreateFace("under", w, d, 1, 0, -h / 2, df*0.5f, -90, 0, 0, Finish[4]); under.transform.SetParent(Panel.transform); GameObject back = CreateFace("back", w, h, 1, 0, 0, d / 2, 0, 180, 0, Finish[5]); back.transform.SetParent(Panel.transform); //Grip1 float eh=7.5f; float posy=h*0.5f-2-eh*0.5f; float posz=-(d+ df)*0.5f+df*0.5f; GameObject E_left = CreateFace("E_left", df, eh, 1, -w / 2, posy,posz, 0, 90, 0, Finish[0]); E_left.transform.SetParent(Panel.transform); GameObject E_right = CreateFace("E_right", df, eh, 1, w / 2, posy,posz, 0, -90, 0, Finish[1]); E_right.transform.SetParent(Panel.transform); GameObject E_top = CreateFace("E_top", w, df, 1, 0, posy+eh*0.5f,posz, 90, 0, 0, Finish[2]); E_top.transform.SetParent(Panel.transform); GameObject E_front = CreateFace("E_front", w, eh, 1, 0, posy, posz-df*0.5f, 0, 0, 0, Finish[3]); E_front.transform.SetParent(Panel.transform); GameObject E_under = CreateFace("E_under", w, df, 1, 0, posy-eh*0.5f, posz, -90, 0, 0, Finish[4]); E_under.transform.SetParent(Panel.transform); GameObject E_back = CreateFace("E_back", w, eh, 1, 0, posy, posz+df*0.5f, 0, 180, 0, Finish[5]); E_back.transform.SetParent(Panel.transform); //Grip2 float eh2=7.5f; posy=h*0.5f-2-eh-2.5f-eh*0.5f; GameObject E2_left = CreateFace("E2_left", df, eh2, 1, -w / 2, posy,posz, 0, 90, 0, Finish[0]); E2_left.transform.SetParent(Panel.transform); GameObject E2_right = CreateFace("E2_right", df, eh2, 1, w / 2, posy,posz, 0, -90, 0, Finish[1]); E2_right.transform.SetParent(Panel.transform); GameObject E2_top = CreateFace("E2_top", w, df, 1, 0, posy+eh*0.5f,posz, 90, 0, 0, Finish[2]); E2_top.transform.SetParent(Panel.transform); GameObject E2_front = CreateFace("E2_front", w, eh2, 1, 0, posy, posz-df*0.5f, 0, 0, 0, Finish[3]); E2_front.transform.SetParent(Panel.transform); GameObject E2_under = CreateFace("E2_under", w, df, 1, 0, posy-eh*0.5f, posz, -90, 0, 0, Finish[4]); E2_under.transform.SetParent(Panel.transform); GameObject E2_back = CreateFace("E2_back", w, eh2, 1, 0, posy, posz+df*0.5f, 0, 180, 0, Finish[5]); E2_back.transform.SetParent(Panel.transform); //Grip3 float eh3=8; posy=-h*0.5f+eh3*0.5f; GameObject E3_left = CreateFace("E3_left", df, eh3, 1, -w / 2, posy,posz, 0, 90, 0, Finish[0]); E3_left.transform.SetParent(Panel.transform); GameObject E3_right = CreateFace("E3_right", df, eh3, 1, w / 2, posy,posz, 0, -90, 0, Finish[1]); E3_right.transform.SetParent(Panel.transform); GameObject E3_top = CreateFace("E3_top", w, df, 1, 0, posy+eh*0.5f,posz, 90, 0, 0, Finish[2]); E3_top.transform.SetParent(Panel.transform); GameObject E3_front = CreateFace("E3_front", w, eh3, 1, 0, posy, posz-df*0.5f, 0, 0, 0, Finish[3]); E3_front.transform.SetParent(Panel.transform); GameObject E3_under = CreateFace("E3_under", w, df, 1, 0, posy-eh*0.5f, posz, -90, 0, 0, Finish[4]); E3_under.transform.SetParent(Panel.transform); GameObject E3_back = CreateFace("E3_back", w, eh3, 1, 0, posy, posz+df*0.5f, 0, 180, 0, Finish[5]); E3_back.transform.SetParent(Panel.transform); } Panel.transform.position = new Vector3(px, py, pz); return Panel; } public static Dictionary _Recipe= new() { { "B1_S1", "S_I_T_F_U_B" }, // header { "B1_S2", "n_n_T_I_U_B" }, // header { "B1_S3", "I_S_T_F_U_B" }, // header { "B1_Under", "n_n_I_F_S_n" }, // header { "B1_Top", "n_n_S_F_I_n" }, // header }; public static GameObject Shelf(string Name, float sx, float sy, float sz, float px, float py, float pz, float rx, float ry, float rz, string texcode) { if (texcode.Split('?').Length == 1) texcode += "?0"; // GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); string Melamine = "TEXT.1.1?#FFFFFF?#FFFFFF?#FFFFFF?1?0?0.5?0.05?1"; Vector3 Size = new(sx,sy,sz); //string[] FINISH = new string[] { texcode, Melamine, Melamine, Melamine,Melamine, Melamine}; string[] FINISH = new string[] { texcode, texcode, texcode ,texcode,texcode, texcode}; GameObject obj = DOSIDE.Make_Cube( Name, Size, FINISH); obj.name = Name; // obj.GetComponent().enabled = false; //obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.position = new Vector3(px, py, pz); obj.transform.rotation = Quaternion.Euler(rx, ry, rz); //obj.GetComponent().material = Instantiate(_G.TEXTURE); //SetMat(obj, texcode); //DOIT.SetSizeTex(obj, 1 * 12, 1 * 12, 90, 90, 90, 90, 0, 0); return obj; } public static GameObject Filler(string Name, float sx, float sy, float sz, float px, float py, float pz, float rx, float ry, float rz, string texcode) { //if (texcode.Split('?').Length == 1) texcode +="?0"; //=F1_1?1?90?2.5 print("texcode============"+texcode); //texcode============??90? string[] codetexture=texcode.Split('?'); texcode= codetexture[1]+"?"+codetexture[2]; GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.name = Name; obj.GetComponent().enabled = false; obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.SetPositionAndRotation(new Vector3(px, py, pz), Quaternion.Euler(rx, ry, rz)); //obj.GetComponent().material = Instantiate(_G.CABMAT); obj.GetComponent().material=UIT_MATERIAL.GetMaterial(codetexture[1]); //SetMat(obj, texcode); DOIT.SetSizeTex(obj, 2 * 12, 2 * 12, 0, 0, 0, 0, 90, 90); return obj; } public static void SetMat(GameObject obj, string texcode) { //int("texcod===="+texcode);//texcod====Mellamine?0 if(texcode=="MELAMINEWHITE" || texcode.IndexOf("Mellamine")!=-1){ texcode="1?0"; texcode="TEXT.1.1?#FCFFFE#?FCFFFE?#FCFFFE?1?0?0.5?0.05?1"; } //int("texcode===="+texcode); obj.GetComponent().material = UIT_MATERIAL.GetMaterial(texcode); //obj.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; } public static GameObject CreateFace(string n, float sx, float sy, float sz, float px, float py, float pz, float rx, float ry, float rz, string texcode){ GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Quad); obj.transform.localScale = new Vector3(sx, sy, sz); obj.transform.position = new Vector3(px, py, pz); obj.transform.localRotation = Quaternion.Euler(rx, ry, rz); obj.tag = "bloc"; obj.name = n; obj.GetComponent().enabled = false; obj.GetComponent().material = Instantiate(_G.TEXTURE); SetMat(obj, texcode); //obj.GetComponent().material = MAT;//Instantiate(_G.MATTEXTURES);//Resources.Load("MATERIALS/ST") as Material; //Texture DOIT.SetSizeTex(obj, 48, 48, 0, 0, 0, 0, 90, 90); obj.GetComponent().probeAnchor = GameObject.Find("Reflection Probe").transform; return obj; } }