public void CreateVoid() { LayerMask cLevel = selectedObjects[0].layer; GameObject tempRoom = MergeMesh(); CurrentRoom = tempRoom; CurrentRoom.tag = "exterior"; CurrentRoom.AddComponent <MeshRenderer>(); CurrentRoom.AddComponent <MeshCollider>(); CurrentRoom.GetComponent <Renderer>().material = matExterior; CurrentRoom.transform.SetParent(parentExterior.transform); CurrentRoom.name = "Exterior"; GameObject nameText = new GameObject(); nameText.AddComponent <TMPro.TextMeshPro>(); nameText.GetComponent <TMPro.TextMeshPro>().text = "Exterior"; nameText.transform.position = CurrentRoom.GetComponent <Renderer>().bounds.center + new Vector3(0, 0.1f, 0); nameText.transform.parent = CurrentRoom.transform; nameText.GetComponent <TextMesh>().alignment = TextAlignment.Center; nameText.GetComponent <TMPro.TextMeshPro>().alignment = TMPro.TextAlignmentOptions.Center; nameText.GetComponent <TMPro.TextMeshPro>().fontSize = 10; nameText.transform.localRotation = Quaternion.Euler(90, 0, 0); CurrentRoom.layer = cLevel; nameText.layer = cLevel; Deselect(); }
/// <summary> /// adding the name as text to the displayed room mesh /// this is where we would also initialise serialisation (to pass to the next configurator) /// </summary> public void NameRoom() { //var tiles = GameObject.FindGameObjectsWithTag("tile"); string rname = inputText.text; CurrentRoom.name = rname; GameObject nameText = new GameObject(); nameText.transform.SetParent(CurrentRoom.transform); nameText.AddComponent <TMPro.TextMeshPro>(); nameText.GetComponent <TMPro.TextMeshPro>().text = rname + "\n " + (Math.Round(currentArea)).ToString() + " m²"; nameText.name = (Math.Round(currentArea)).ToString() + " m²"; nameText.transform.position = CurrentRoom.GetComponent <Renderer>().bounds.center + new Vector3(0, 0.1f, 0); nameText.transform.parent = CurrentRoom.transform; nameText.GetComponent <TMPro.TextMeshPro>().alignment = TMPro.TextAlignmentOptions.Center; nameText.GetComponent <TMPro.TextMeshPro>().fontSize = 10; CurrentRoom.GetComponent <EG_room>().Name = rname; StartCoroutine(FindObjectOfType <VisibilityController>().DelayStart()); nameText.transform.localRotation = Quaternion.Euler(90, 0, 0); nameText.layer = CurrentRoom.layer; }
/// <param name="rType"> room type comes with a set of parameters defining creation criteria; currently embedded in a json </param> public void CreateRoom(string rType, float minSize, Color rColour, Color rColourO, bool circ) { // check whether there are no disjointed segments LayerMask cLevel = selectedObjects[0].layer; if (AllMeshesHasCommonEdges(selectedObjects)) { GameObject tempRoom = MergeMesh(); float rArea = CalculateSurfaceArea(tempRoom.GetComponent <MeshFilter>().sharedMesh); currentArea = rArea; // find closest level and its height var height = tempRoom.GetComponent <MeshFilter>().sharedMesh.bounds.center.y; Tuple <float, float> levelParams = FindAssociatedHeightAndLevel(height); var vertices2D = Outline2DArray(tempRoom.GetComponent <MeshFilter>().mesh); float delay = 0f; if (minSize > rArea) { StartCoroutine(UIController.DisplayWarning(3f, "Area of the room (" + rArea + "m2) is smaller than minimum area specified for the " + rType + " room type: " + minSize + "m2")); delay = 3f; } // create room CurrentRoom = tempRoom; CurrentRoom.tag = "room"; CurrentRoom.AddComponent <MeshRenderer>(); CurrentRoom.AddComponent <MeshCollider>(); CurrentRoom.GetComponent <Renderer>().material = matTemplate; CurrentRoom.GetComponent <Renderer>().material.SetColor("_Color", rColour); CurrentRoom.GetComponent <Renderer>().material.SetColor("_FirstOutlineColor", rColourO); CurrentRoom.AddComponent <EG_room>(); CurrentRoom.GetComponent <EG_room>().Type = rType; CurrentRoom.GetComponent <EG_room>().Area = rArea; CurrentRoom.GetComponent <EG_room>().Vertices = vertices2D; CurrentRoom.GetComponent <EG_room>().Level = levelParams.Item1; CurrentRoom.GetComponent <EG_room>().Height = levelParams.Item2; CurrentRoom.GetComponent <EG_room>().Edges = new List <bool>(); CurrentRoom.GetComponent <EG_room>().Circulation = circ; CurrentRoom.layer = cLevel; CurrentRoom.transform.SetParent(parentRoom.transform); StartCoroutine(UIController.EnableInputField(delay)); } else { StartCoroutine(UIController.DisplayWarning(3f, "Room can be created only from tiles that have at least one common edge.")); foreach (GameObject obj in selectedObjects) { obj.SetActive(true); } } Deselect(); }