private void AddToRoot(int index) { if (_objectList == null) { _objectList = new List <GameObject>(); } _objectList.Add(Instantiate(_roomObjects.Fixtures[index].GetPrefab3d(), _rootObject.transform)); _objectList[index].transform.localScale = _roomObjects.ScaleAt(index); //add components if (!_objectList[index].CompareTag("Ground")) { Rigidbody rb = _objectList[index].AddComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = true; _objectList[index].AddComponent <SelectGlow>(); } if (_moveState) { AddMoveComponent(_objectList[index]); } else if (_rotateState) { AddRotateComponent(_objectList[index]); } else if (_elevateState) { AddElevateComponent(_objectList[index]); } //add position recorder }
private void StartPreviewRender() { if (_renderCamera != null) { Destroy(_renderCamera); } // create and position camera _renderCamera = Instantiate(_previewRenderer); _renderCamera.transform.position = _defaultCameraPosition; // set object to render in camera Camera cam = _renderCamera.GetComponentInChildren <Camera>(); cam.targetTexture = _renderTexture; for (int i = 0; i < _roomObjects.Fixtures.Count; i++) { GameObject model = Instantiate(_roomObjects.Fixtures[i].GetPrefab3d(), _renderCamera.transform.GetChild(0)); model.layer = _renderLayer; foreach (var child in model.GetComponentsInChildren(typeof(Transform), true)) { child.gameObject.layer = _renderLayer; } if (_roomObjects.Fixtures[i].IsOfType("Hideable")) { AddTransparency(model); } model.transform.localScale = _roomObjects.ScaleAt(i); model.transform.localPosition = _roomObjects.PosAt(i); model.transform.localEulerAngles = _roomObjects.RotAt(i); _previewObjects.Add(model); } UpdateCameraView(); }
private void CreateRoomTemplate() { FixtureContainerSO statics = _settingsSO.StaticFixtureSOList; List <FixtureSO> prefabs = statics.Fixtures; _roomTemplate = new GameObject("RoomTemplate"); for (int i = 0; i < prefabs.Count; i++) { GameObject fixture = Instantiate(prefabs[i].GetPrefab3d(), _roomTemplate.transform); fixture.transform.localScale = statics.ScaleAt(i); fixture.transform.localPosition = statics.PosAt(i); fixture.transform.localEulerAngles = statics.RotAt(i); Fixture fixtureScript = fixture.AddComponent <Fixture>(); fixtureScript.FixtureSO = prefabs[i]; } _roomTemplate.SetActive(false); }