// Update is called once per frame void Update() { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit) && hit.collider.tag == "gridElement") { this.transform.position = hit.collider.transform.position; lastHit = hit.collider.gameObject.GetComponent <gridElement>(); this.rectTransform.sizeDelta = new Vector2(1.0f, lastHit.GetElementHeight()); if (Input.GetMouseButtonDown(1)) { SetCurserButton(0); } } // reset when press 5 //read a file, instantiate a constructor by width height. then read an array to enable and disable gridElement. if (Input.GetKeyDown("5")) { constructor.instance.freeMemory(); constructor.instance.initialize(10, 2); } //save file if (Input.GetKeyDown("1")) { XMLOp.Serialize(constructor.instance.info, "constructorInfo.xml"); } if (Input.GetKeyDown("2")) { constructorInfo outInfo = new constructorInfo(); outInfo = XMLOp.Deserialize <constructorInfo>("constructorInfo.xml"); constructor.instance.info.width = outInfo.width; constructor.instance.info.height = outInfo.height; constructor.instance.freeMemory(); constructor.instance.initialize(outInfo.width, outInfo.height); for (int i = 0; i < outInfo.width * outInfo.width * outInfo.height; i++) { if (outInfo.gridElementStatus[i] == 0) { Debug.Log(i); constructor.instance.info.gridElementStatus[i] = 0; constructor.instance.gridElements[i].SetDisable(); } else { constructor.instance.info.gridElementStatus[i] = 1; constructor.instance.gridElements[i].SetEnable(); } } } }
// Update is called once per frame void Update() { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit) && hit.collider.tag == "gridElement") { this.transform.position = hit.collider.transform.position; lastHit = hit.collider.gameObject.GetComponent <gridElement>(); this.transform.localScale = new Vector3(1, 1, 1); this.rectTransform.sizeDelta = new Vector2(1.0f, lastHit.GetElementHeight()); if (Input.GetMouseButtonDown(1)) { SetCurserButton(0); } } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0)) { hitSomething = Physics.Raycast(ray, out hit); } ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (GameObject.Find("CanvasPause").GetComponent <PauseMenu>().GameIsPaused == false && Physics.Raycast(ray, out hit) && hit.collider.tag == "gridElement") { this.transform.position = hit.collider.transform.position; lastHit = hit.collider.gameObject.GetComponent <gridElement>(); this.rectTransform.sizeDelta = new Vector2(1.0f, lastHit.GetElementHeight()); if (Input.GetMouseButtonDown(1)) { SetCurserButton(0); } } }