protected override void AddListenerForPanelFields() { base.AddListenerForPanelFields(); var panel = Panel.transform; var textureTypeDropdown = panel.GetChild(0).GetComponent <TMP_Dropdown>(); textureTypeDropdown.AddOptions(new List <string> { "Regular", "360 Image" }); textureTypeDropdown.onValueChanged.AddListener( (int option) => { updateTextureType = (EDanbiTextureType)option; DanbiUISync.onPanelUpdate?.Invoke(this); } ); var selectTextureButton = panel.GetChild(1).GetComponent <Button>(); selectTextureButton.onClick.AddListener(() => StartCoroutine(Coroutine_SelectTargetTexture())); m_texturePreviewRawImage = panel.GetChild(2).GetComponent <RawImage>(); m_textureResolutionText = panel.GetChild(3).GetComponent <TextMeshProUGUI>(); m_textureNameText = panel.GetChild(4).GetComponent <TextMeshProUGUI>(); LoadPreviousValues(); }
void OnTextureTypeChange(EDanbiTextureType type) { m_texType = type; switch (m_texType) { case EDanbiTextureType.Regular: m_panoramaRegular.gameObject.SetActive(true); m_panorama360.gameObject.SetActive(false); m_panorama4faces.gameObject.SetActive(false); break; case EDanbiTextureType.Faces4: m_panoramaRegular.gameObject.SetActive(false); m_panorama360.gameObject.SetActive(false); m_panorama4faces.gameObject.SetActive(true); break; case EDanbiTextureType.Panorama: m_panoramaRegular.gameObject.SetActive(false); m_panorama360.gameObject.SetActive(true); m_panorama4faces.gameObject.SetActive(false); break; } RebuildMeshShape(); RebuildMeshInfo(); }
protected override void LoadPreviousValues(params Selectable[] uiElements) { m_textureType = (EDanbiTextureType)PlayerPrefs.GetInt("ImageProjection-textureType", default); string prevTexturePath = PlayerPrefs.GetString("ImageProjection-texturePath", default); m_loadedTex = Resources.Load <Texture2D>(prevTexturePath); UpdateTexturePreview(m_loadedTex); DanbiUISync.onPanelUpdate?.Invoke(this); }
protected override void AddListenerForPanelFields() { base.AddListenerForPanelFields(); var panel = Panel.transform; var panelRect = Panel.GetComponent <RectTransform>(); m_loadedTextures = new List <Texture2D>(); // locate upward a little bit. // panelRect.anchoredPosition = new Vector2(panelRect.anchoredPosition.x, panelRect.anchoredPosition.y + 30.0f); // change the panel size. m_originalSize = panelRect.sizeDelta; m_4facesSize = new Vector2(panelRect.sizeDelta.x * 2.0f, panelRect.sizeDelta.y * 2.0f); // 1. bind Texture Type Dropdown var textureTypeDropdown = panel.GetChild(0).GetComponent <TMP_Dropdown>(); textureTypeDropdown.AddOptions(new List <string> { "Regular", "360 Image", "4 Faces" }); textureTypeDropdown.onValueChanged.AddListener( (int option) => { updateTextureType = (EDanbiTextureType)option; m_loadedTextures.Clear(); if ((EDanbiTextureType)option == EDanbiTextureType.Faces4) { TogglePreviewsOn4FacesTextureType(true); SetUILayoutOnTextureType(true, panelRect); } else { TogglePreviewsOn4FacesTextureType(false); SetUILayoutOnTextureType(false, panelRect); } onTextureTypeChange?.Invoke(m_textureType); } ); // 2. bind first texture. Transform firstTexTf = panel.GetChild(1); m_selectTextureButtons[0] = firstTexTf.GetChild(0).GetComponent <Button>(); m_selectTextureButtons[0].onClick.AddListener( () => { StartCoroutine(Coroutine_SelectTargetTexture(m_texturePaths[0], 0)); }); m_texturePreviewRawImages[0] = firstTexTf.GetChild(1).GetComponent <RawImage>(); m_textureResolutionsTexts[0] = firstTexTf.GetChild(2).GetComponent <TMP_Text>(); m_textureNamesTexts[0] = firstTexTf.GetChild(3).GetComponent <TMP_Text>(); Vector2 firstSelectTextureButtonPos = m_selectTextureButtons[0].GetComponent <RectTransform>().anchoredPosition; Vector2 firstPrevieRawImagePos = m_texturePreviewRawImages[0].rectTransform.anchoredPosition; Vector2 firstResolutionText = m_textureResolutionsTexts[0].rectTransform.anchoredPosition; Vector2 firstNameText = m_textureNamesTexts[0].rectTransform.anchoredPosition; float positionOffsetX = 220.0f; float positionOffsetY = -240.0f; // 3. bind second texture Transform secondTexTf = panel.GetChild(2); m_selectTextureButtons[1] = secondTexTf.GetChild(0).GetComponent <Button>(); m_selectTextureButtons[1].onClick.AddListener( () => { StartCoroutine(Coroutine_SelectTargetTexture(m_texturePaths[1], 1)); }); m_texturePreviewRawImages[1] = secondTexTf.GetChild(1).GetComponent <RawImage>(); m_textureResolutionsTexts[1] = secondTexTf.GetChild(2).GetComponent <TMP_Text>(); m_textureNamesTexts[1] = secondTexTf.GetChild(3).GetComponent <TMP_Text>(); m_selectTextureButtons[1].GetComponent <RectTransform>().anchoredPosition = firstSelectTextureButtonPos + new Vector2(positionOffsetX, 0.0f); m_texturePreviewRawImages[1].rectTransform.anchoredPosition = firstPrevieRawImagePos + new Vector2(positionOffsetX, 0.0f); m_textureResolutionsTexts[1].rectTransform.anchoredPosition = firstResolutionText + new Vector2(positionOffsetX, 0.0f); m_textureNamesTexts[1].rectTransform.anchoredPosition = firstNameText + new Vector2(positionOffsetX, 0.0f); // 4. bind third texture Transform thirdTexTf = panel.GetChild(3); m_selectTextureButtons[2] = thirdTexTf.GetChild(0).GetComponent <Button>(); m_selectTextureButtons[2].onClick.AddListener( () => { StartCoroutine(Coroutine_SelectTargetTexture(m_texturePaths[2], 2)); }); m_texturePreviewRawImages[2] = thirdTexTf.GetChild(1).GetComponent <RawImage>(); m_textureResolutionsTexts[2] = thirdTexTf.GetChild(2).GetComponent <TMP_Text>(); m_textureNamesTexts[2] = thirdTexTf.GetChild(3).GetComponent <TMP_Text>(); m_selectTextureButtons[2].GetComponent <RectTransform>().anchoredPosition = firstSelectTextureButtonPos + new Vector2(firstPrevieRawImagePos.x - 30.0f, positionOffsetY); m_texturePreviewRawImages[2].rectTransform.anchoredPosition = firstPrevieRawImagePos + new Vector2(firstPrevieRawImagePos.x - 30.0f, positionOffsetY); m_textureResolutionsTexts[2].rectTransform.anchoredPosition = firstResolutionText + new Vector2(firstPrevieRawImagePos.x - 30.0f, positionOffsetY); m_textureNamesTexts[2].rectTransform.anchoredPosition = firstNameText + new Vector2(firstPrevieRawImagePos.x - 30.0f, positionOffsetY); // 5. bind fourth texture Transform fourthTexTf = panel.GetChild(4); m_selectTextureButtons[3] = fourthTexTf.GetChild(0).GetComponent <Button>(); m_selectTextureButtons[3].onClick.AddListener( () => { StartCoroutine(Coroutine_SelectTargetTexture(m_texturePaths[3], 3)); }); m_texturePreviewRawImages[3] = fourthTexTf.GetChild(1).GetComponent <RawImage>(); m_textureResolutionsTexts[3] = fourthTexTf.GetChild(2).GetComponent <TMP_Text>(); m_textureNamesTexts[3] = fourthTexTf.GetChild(3).GetComponent <TMP_Text>(); m_selectTextureButtons[3].GetComponent <RectTransform>().anchoredPosition = firstSelectTextureButtonPos + new Vector2(positionOffsetX, positionOffsetY); m_texturePreviewRawImages[3].rectTransform.anchoredPosition = firstPrevieRawImagePos + new Vector2(positionOffsetX, positionOffsetY); m_textureResolutionsTexts[3].rectTransform.anchoredPosition = firstResolutionText + new Vector2(positionOffsetX, positionOffsetY); m_textureNamesTexts[3].rectTransform.anchoredPosition = firstNameText + new Vector2(positionOffsetX, positionOffsetY); // 6. init textures. for (int i = 0; i < 4; ++i) { m_textureResolutionsTexts[i].text = "Resolution : ---"; m_textureNamesTexts[i].text = "Texture Name : ---"; } // 7. these 4faces textures are turned on only when the type is "4faces", so turned them all off by default. TogglePreviewsOn4FacesTextureType(false); LoadPreviousValues(); }