using UnityEngine.UI; using UnityEngine; using UnityEngine.EventSystems; using System.Collections; using System.Net; using System.Net.Sockets; using UnityEngine.Networking; using System.Text; using System.Globalization; using TMPro; using System.Collections.Generic; using System; public class MenuScript : MonoBehaviour { public delegate void MobileDetected(bool isMobile); public MobileDetected _OnMobileDetected; AutoRotate _autoRotate; [HideInInspector] public GameObject Pnl_plan2d; [HideInInspector] public GameObject Pnl_start; [HideInInspector] public GameObject Pnl_ShowPlan; [HideInInspector] public GameObject Pnl_scene; [HideInInspector] public GameObject MainPnl; [SerializeField,HideInInspector] GameObject _touchInputPanel; [SerializeField] Paths _path = Paths.Ukitchenit; public static float timeKeyHold=0; public static float timePassed=0; //----------------------------------------Start----------------------------------------------------------------- private void Awake() { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; SetVersionNumberFromProjectSettings(); _autoRotate = Camera.main.GetComponent(); SetFrameRate(); _touchInputPanel.SetActive(false); } public void Start() { #if !UNITY_WEBGL //int kernelHandle = computeShader.FindKernel("BlendScenarios"); // computeShader.Dispatch(kernelHandle, ...); #endif #if UNITY_WEBGL if(Application.absoluteURL.IndexOf("free")!=-1 && Application.absoluteURL.IndexOf("3d")!=-1 || Application.absoluteURL.IndexOf("Free")!=-1 && Application.absoluteURL.IndexOf("sd")!=-1 ) { Link.OpenWindow("free","https://ukitchenit.com/free/");return; } #endif Application.targetFrameRate=-1; SceneModeManager.Instance.SetSceneModeVisibility(); ReadURL.path(); CheckForPath(); //_G.UseNewCsvFormat = _G.CheckIfLibraryUseNewFormat(_G.PATH); //WebGLInput.captureAllKeyboardInput=false; //_G.PATH="BMR"; _G.PATH=_G.PATH.ToLower(); Load_G(); //_G.BKN = 1;//Backup number add when saving on cloud backup //_G.status = "nJN";//status Form or not (new no JN, old, JN //nJN,old,JN) _G.OBJs[299] = new string[100]; _G.OBJs[299][0] = "null"; _G.OBJs[299][1] = "null"; //_G.L = 2;//French DOIT.CloseALLPNL(); Pnl_start.SetActive(true); Pnl_ShowPlan.SetActive(false); Pnl_scene.SetActive(false); TRANS.go(); for (int i = 1; i < 25; i++) { _G. WallsMaterial[i - 1] = _G.GYPSE; _G. WallsTexture[i - 1] = "GypseHorizontal"; } _G.ceilm = _G.GYPSECEIL; _G.ceilt = "GypseHorizontal"; SceneModeManager.Instance.SetSceneMode(SceneModes.Start); UIT_LoadLibrary.Load(); Get.o2("HIDER", "Login").SetActive(false); Get.o2("Canvas", "PATH").GetComponent().text = _G.PATH; DASH.HDset(false); //SelectLight.Setexposer(0); //LanguageSelection(); Get.o2("Canvas/Panel_main","TEMPLATE").SetActive(_G.PATH=="laminam"); } private void SetVersionNumberFromProjectSettings() { _G.VER = Application.version; } private static void SetFrameRate() { #if !UNITY_EDITOR && UNITY_WEBGL Debug.Log("This is a WebGL build"); _G.IsEditor = false; // Code specific to WebGL build Application.targetFrameRate = -1; #endif #if UNITY_EDITOR // Code specific to the Unity Editor build Debug.Log("This is the Unity Editor build"); _G.IsEditor = true; QualitySettings.vSyncCount = 0; Application.targetFrameRate = -1; #endif #if UNITY_STANDALONE // Code specific to standalone platforms (Windows, macOS, Linux) _G.IsEditor = false; Debug.Log("This is a standalone build"); QualitySettings.vSyncCount = 0; Application.targetFrameRate = -1; #endif #if UNITY_ANDROID // Code specific to Android build _G.IsEditor = false; Debug.Log("This is an Android build"); Application.targetFrameRate = -1; #endif #if UNITY_IOS // Code specific to iOS build _G.IsEditor = false; Debug.Log("This is an iOS build"); Application.targetFrameRate = -1; #endif } void CheckForPath() { if (!string.IsNullOrEmpty(_G.PATH)) return; // Initialize Key for Path // to switch key remove last variable name write Paths add the dot "." , and you should see every path defined in _G Paths path = _path; if (!_G._Paths.ContainsKey(path)) { Debug.Log("No path defined in _G for " + path.ToString()); return; } _G.PATH = _G._Paths[path]; } void Update() { bool isMouseInsideScreenBoundaries = MouseCheck.InOut(); if (isMouseInsideScreenBoundaries == false && !SceneModeManager.CompareSceneMode(SceneModes.MouseOut)) { SceneModeManager.Instance.OnMouseOut(); } if (isMouseInsideScreenBoundaries && !SceneModeManager.CompareSceneMode(SceneModes.MouseOut))//if mouse is in sofware action { //print("_G.SM=="+_G.SM); bool isPanal=Get.o2("Canvas","Panel_SCENE").activeInHierarchy; if (!EventSystem.current.IsPointerOverGameObject() && !SceneModeManager.CompareSceneMode(SceneModes.Plan2D) && isPanal) { HitObject.CheckHIT(); } ColorSet.Do(); GameObject newEmptyGameObject = GameObject.Find("New Game Object"); if (newEmptyGameObject) Destroy(newEmptyGameObject); if (!SceneModeManager.CompareSceneMode(SceneModes.Plan2D) && !SceneModeManager.CompareSceneMode(SceneModes.ShowTips) && !SceneModeManager.CompareSceneMode(SceneModes.CounterView) && !SceneModeManager.CompareSceneMode(SceneModes.ZoomTouch) && !SceneModeManager.CompareSceneMode(SceneModes.Ai)) { //Navigate setup GameObject[] MENU = GameObject.FindGameObjectsWithTag("Menu"); GameObject[] PNL = GameObject.FindGameObjectsWithTag("pnl"); //bool isSelectedAndMenuShouldNormalyBeOpen = SceneModeManager.CompareSceneMode(SceneModes.ReadyMove) || SceneModeManager.CompareSceneMode(SceneModes.Move) || SceneModeManager.CompareSceneMode(SceneModes.SlidingHandle) || SceneModeManager.CompareSceneMode(SceneModes.RotationHandle); // menu or panel are open will be stored in array and so we must be in panel mode if (MENU.Length != 0 || PNL.Length != 0 || _G.NAVIGATE == false /*|| _G.LockInState*/) { if (!_G.LockInState) { if (SceneModeManager.CompareSceneMode(SceneModes.Navigate) || _G.NAVIGATE == false) { if (!SceneModeManager.CompareSceneMode(SceneModes.Paint) && !SceneModeManager.CompareSceneMode(SceneModes.Measure) && !SceneModeManager.CompareSceneMode(SceneModes.Align) && !SceneModeManager.CompareSceneMode(SceneModes.Plan2D) && !SceneModeManager.CompareSceneMode(SceneModes.GroupMove) && !SceneModeManager.CompareSceneMode(SceneModes.Move) && !SceneModeManager.CompareSceneMode(SceneModes.Hit) && !SceneModeManager.CompareSceneMode(SceneModes.Duplicate) && !SceneModeManager.CompareSceneMode(SceneModes.ReadyMove)) { //_G.SM = SceneModes.Panel /*"pnl"*/; SceneModeManager.Instance.SetSceneMode(SceneModes.Panel); } } } } else { //Debug.Log("Navigate == " + _G.NAVIGATE); SceneModeManager.Instance.SetSceneMode(SceneModes.Navigate); } } // if(GameObject.Find("MainCamera").activeInHierarchy){ // if (!SceneModeManager.CompareSceneMode(SceneModes.CounterView) && !SceneModeManager.CompareSceneMode(SceneModes.Plan2D) && !SceneModeManager.CompareSceneMode(SceneModes.Calcule)) { Camera.main.GetComponent().Hide(); } // if (!SceneModeManager.CompareSceneMode(SceneModes.CounterView)) HideTopWall(); // } } timePassed += Time.deltaTime; if(timePassed > 0.05f) { TRANS.go(); //CAPSSHOW(); BTN_Hide.ShowBTNS(); timePassed = 0f; } COLORSET.On(); HandleKeyboardInput(); //hide object for (int i = 0; i < _G.HIDELIST.Count; i++) { GameObject go = GameObject.Find(_G.HIDELIST[i]); if (go != null) { go.SetActive(false); } } //COLORSET.On(); _G.NAVIGATE = true; //Make Directlight off when no openning in scene if (!SceneModeManager.CompareSceneMode(SceneModes.CounterView) && !SceneModeManager.CompareSceneMode(SceneModes.Plan2D) && !SceneModeManager.CompareSceneMode(SceneModes.Calcule)) { if (SelectLight.OpenOnScene() && _G.HD == true) { Get.o2("LIGHTS/ONOFF", "Sun").SetActive(true); } else if (!SelectLight.OpenOnScene() && _G.HD == true) { if (Get.o2("LIGHTS/ONOFF", "Directional Light") != null) Get.o2("LIGHTS/ONOFF", "Directional Light").SetActive(false); } } if (isMouseInsideScreenBoundaries && SceneModeManager.CompareSceneMode(SceneModes.MouseOut)) { SceneModeManager.Instance.OnMouseIn(); } BTN_Hide.ShowBTNS(); if(SceneModeManager.Selected!=null){ if(timeKeyHold==0 || timeKeyHold>30){ GameObject sel = SceneModeManager.Selected; int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); if(!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift) ) { Vector3 SelPosition=sel.transform.position; float CamY=Camera.main.transform.eulerAngles.y; //print("CamY===="+CamY); float X = 0; float Z = 0; float Y = 0; if(_G.OBJs[nO][22]=="floor"){ if(CamY>315 || CamY<45){ if (Input.GetKey(KeyCode.DownArrow))Z-=1; else if (Input.GetKey(KeyCode.LeftArrow))X-=1; else if (Input.GetKey(KeyCode.RightArrow))X+=1; else if (Input.GetKey(KeyCode.UpArrow))Z+=1;; } if(CamY<=315 && CamY>=225){ if (Input.GetKey(KeyCode.DownArrow))X+=1; else if (Input.GetKey(KeyCode.LeftArrow))Z-=1; else if (Input.GetKey(KeyCode.RightArrow))Z+=1; else if (Input.GetKey(KeyCode.UpArrow))X-=1; } if(CamY<225 && CamY>135){ if (Input.GetKey(KeyCode.DownArrow))Z+=1; else if (Input.GetKey(KeyCode.LeftArrow))X+=1; else if (Input.GetKey(KeyCode.RightArrow))X-=1; else if (Input.GetKey(KeyCode.UpArrow))Z-=1; } if(CamY<=135 && CamY>=45){ if (Input.GetKey(KeyCode.DownArrow))X-=1; else if (Input.GetKey(KeyCode.LeftArrow))Z+=1; else if (Input.GetKey(KeyCode.RightArrow))Z-=1; else if (Input.GetKey(KeyCode.UpArrow))X+=1; } sel.transform.position=new(SelPosition.x+X,SelPosition.y+Y,SelPosition.z+Z); } if(_G.OBJs[nO][22]!="floor"){ if (Input.GetKey(KeyCode.LeftArrow)) {sel.transform.position-=sel.transform.right;} if (Input.GetKey(KeyCode.RightArrow)){sel.transform.position+=sel.transform.right;} if (Input.GetKey(KeyCode.DownArrow)){sel.transform.position-=sel.transform.forward;} if (Input.GetKey(KeyCode.UpArrow)) {sel.transform.position+=sel.transform.forward;} } //SceneModeManager.Selected.transform.GetComponent().HandelObjectArrowMove(StartPoint,sel.transform.position,attachedTo.transform); } if(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ) { if(Input.GetKey(KeyCode.DownArrow)){sel.transform.position-=sel.transform.up;} if (Input.GetKey(KeyCode.UpArrow)) {sel.transform.position+=sel.transform.up;} } } } if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.UpArrow)){ if(SceneModeManager.Selected!=null){ timeKeyHold+=1; //TopControl.showMesure(); GameObject sel = SceneModeManager.Selected; Vector3 StartPoint=sel.transform.position; int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); sel.transform.GetComponent().HandelObjectArrowMove(StartPoint,sel.transform.position,_G.OBJs[nO][22]); } } } //--------------------------------------Setting------------------------------------------------------------------ private void HandleKeyboardInput() { //Return key //if (Input.GetKeyDown(KeyCode.Return)) { if (Get.Active("MESURE")) { MesureChange.Changevalue(); } } if (Input.GetMouseButtonUp(0)){ if (_G.HD == true)ReflectionProbesUpdater.Instance.UpdateProbes(); if(SceneModeManager.CompareSceneMode(SceneModes.MoveHandle) && SceneModeManager.Selected.CompareTag("cabwall")) { //_MOL.SetMolding(); } } if (Input.GetMouseButtonDown(0)) { _OnMobileDetected?.Invoke(false); if(SceneModeManager.CompareSceneMode(SceneModes.Navigate)){Get.o2("HIDER","RightClickMenu").SetActive(false);;} } if (Input.touchCount > 0) { //_OnMobileDetected?.Invoke(true); } if (Input.GetKeyDown(KeyCode.Return)) { if (Get.Active("KEYBOARDNUMBER")) { Get.o2("KEYBOARDNUMBER", "btnOK").GetComponent