// Methods // Use this for initialization void Start() { // Get fitting placer script fittingPlacerForUnity = ((FittingPlacerForUnity)FittingPlacerForUnityReferenceGO.GetComponent <FittingPlacerForUnity>()); // Get camera windowCamera = transform.GetComponent <Camera>(); if (DoCapture) { // Set capture save path int captureCount = 1; do { screenCaptureSaveFolderPath = ScreenCaptureSavePath + "/Capture " + captureCount; captureCount++; } while (System.IO.Directory.Exists(screenCaptureSaveFolderPath)); System.IO.Directory.CreateDirectory(screenCaptureSaveFolderPath); } // Get room width to sweep roomWidthCentimeters = 100 * GameObject.FindGameObjectWithTag("Room").GetComponent <RoomController>().Width; if (DoMinimalSweep) { // Set camera sweep to same as smallest room sweep //initialXOffset = -0.75f; // For 4:3 aspect ratio crop initialXOffset = -0.41f; // For 16:9 aspect ratio crop endXOffset = -initialXOffset; } else { // Set room-appropriate camera offset switch ((int)Mathf.Round(roomWidthCentimeters)) { case 350: //initialXOffset = -0.75f; // For 4:3 aspect ratio crop initialXOffset = -0.41f; // For 16:9 aspect ratio crop endXOffset = -initialXOffset; break; case 500: //initialXOffset = -1.44f; // For 4:3 aspect ratio crop initialXOffset = -1.16f; // For 16:9 aspect ratio crop endXOffset = -initialXOffset; break; case 700: //initialXOffset = -2.5f; // For 4:3 aspect ratio crop initialXOffset = -2.16f; // For 16:9 aspect ratio crop endXOffset = -initialXOffset; break; default: // The value is not supported // Setting arbitrary values initialXOffset = -100f; endXOffset = -initialXOffset; break; } } if (ReverseSweep) { float newInitialXOffset = endXOffset; endXOffset = initialXOffset; initialXOffset = newInitialXOffset; } initialXPos = transform.position.x + initialXOffset; endXPos = transform.position.x + endXOffset; float totalTranslationLength = Mathf.Abs(endXOffset - initialXOffset); totalSteps = (int)(totalTranslationLength / StepSize); // Offset the camera to starting position SetPosX(initialXPos); }
// Methods // Use this for initialization void Start() { fittingPlacerForUnity = ((FittingPlacerForUnity)FittingPlacerForUnityReferenceGO.GetComponent <FittingPlacerForUnity>()); // Read door information from door prefab transforms List <float[]> doorData = new List <float[]>(); Transform doorsTransform = transform.Find("Doors"); foreach (Transform doorTransform in doorsTransform) { // Door's x position, y position, breadth, inwards normal angle in radians from the x axis, height, & elevation in meters doorData.Add(new float[] { doorTransform.localPosition.x, doorTransform.localPosition.z, doorTransform.localScale.x, (((-doorTransform.localRotation.eulerAngles.y + 270) % 360) + 360) % 360 * Mathf.PI / 180, doorTransform.localScale.y, doorTransform.localPosition.y - doorTransform.localScale.y / 2 }); } // Read window information from window prefab transforms List <float[]> windowData = new List <float[]>(); Transform windowsTransform = transform.Find("Windows"); foreach (Transform windowTransform in windowsTransform) { // Window's x position, y position, breadth, inwards normal angle in radians from the x axis, height, & elevation in meters windowData.Add(new float[] { windowTransform.localPosition.x, windowTransform.localPosition.z, windowTransform.localScale.x, (((-windowTransform.localRotation.eulerAngles.y + 270) % 360) + 360) % 360 * Mathf.PI / 180, windowTransform.localScale.y, windowTransform.localPosition.y - windowTransform.localScale.y / 2f }); } // Creating the room from: // the rectangular room dimensions (width, depth, height), // the list of arrays for creating the doors, // the list of arrays for creating the windows) roomToFill = new Room( Width, Depth, Height, doorData, windowData, fittingPlacerForUnity.GridCellSize ); // Get the fittings to be placed if (!NamesOfFittingModelsToBePlaced.Equals("")) { // Split fitting models names string by each new line string[] modelsToPlace = NamesOfFittingModelsToBePlaced.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); // Unity adds a carridge return at end of multi-line, public fields strings // If that has not been changed in Unity, remove that ending char if found if (modelsToPlace[modelsToPlace.Length - 1][modelsToPlace[modelsToPlace.Length - 1].Length - 1] == '\r') { modelsToPlace[modelsToPlace.Length - 1] = modelsToPlace[modelsToPlace.Length - 1].Remove(modelsToPlace[modelsToPlace.Length - 1].Length - 1); } fittingModelsToBePlaced.AddRange(modelsToPlace); } else { fittingPlacerForUnity.AreFittingPlacementsFinished = true; } }