public void LoadImages(FileType fileType) { scrollRect.content.transform.Clear(); DetailedImage[] textureDetails = new DetailedImage[0]; switch (fileType) { case FileType.Details: textureDetails = ARDirectoryManager.DetailTextures; break; case FileType.Radiograph: textureDetails = ARDirectoryManager.RadiographTextures; break; case FileType.Movement: textureDetails = ARDirectoryManager.MovementTextures; break; case FileType.Simulation: textureDetails = ARDirectoryManager.SimulationTextures; break; } _textureAmount = textureDetails.Length; _subPanelArray = new ARDetailSubPanel[_textureAmount]; scrollRect.content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.Abs(486 * _textureAmount)); for (int i = 0; i < _textureAmount; i++) { DetailedImage image = textureDetails[i]; GameObject panel = Instantiate(subPanelPrefab); ARDetailSubPanel subPanel = panel.GetComponent <ARDetailSubPanel>(); subPanel.rectTransform.SetParent(scrollRect.content.transform); Sprite sprite = Sprite.Create(image.Texture2D, new Rect(0, 0, image.Texture2D.width, image.Texture2D.height), Vector2.zero); subPanel.SetSprite(sprite); subPanel.SetTitle(image.Title); subPanel.rectTransform.anchoredPosition = new Vector2(0, subPanelResolution.height * -i); subPanel.SetInitialPosition(); _subPanelArray[i] = subPanel; } _currentPanelIndex = 0; _cachedPanelIndex = _currentPanelIndex; targetPosition = _subPanelArray[0].initialPosition; }
public void LoadImages(Texture2D[] textureArray) { scrollRect.content.transform.Clear(); int textureAmount = textureArray.Length; _subPanelArray = new ARDetailSubPanel[textureAmount]; scrollRect.content.rect.Set(0, 0, scrollRect.content.rect.width, subPanelResolution.height * textureAmount); for (int i = 0; i < textureAmount; i++) { GameObject panel = Instantiate(subPanelPrefab); ARDetailSubPanel subPanel = panel.GetComponent <ARDetailSubPanel>(); subPanel.rectTransform.SetParent(scrollRect.content.transform); //subPanel.rawImage.texture = textureArray[i]; subPanel.rectTransform.anchoredPosition = new Vector2(0, subPanelResolution.height * -i); subPanel.SetInitialPosition(); _subPanelArray[i] = subPanel; } }